2021-02-03 20:25:52 +01:00
|
|
|
# NOTE: Make sure to (re-)format this file on changes with `nixpkgs-fmt`!
|
|
|
|
|
2020-10-27 23:28:29 +01:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchFromGitHub
|
2020-11-01 15:35:11 +01:00
|
|
|
, fetchpatch
|
2020-10-25 09:38:02 +01:00
|
|
|
, buildPackages
|
2020-10-27 23:28:29 +01:00
|
|
|
, ninja
|
|
|
|
, meson
|
|
|
|
, m4
|
2021-01-19 07:50:56 +01:00
|
|
|
, pkg-config
|
2020-10-27 23:28:29 +01:00
|
|
|
, coreutils
|
|
|
|
, gperf
|
|
|
|
, getent
|
|
|
|
, patchelf
|
|
|
|
, glibcLocales
|
|
|
|
, glib
|
|
|
|
, substituteAll
|
|
|
|
, gettext
|
|
|
|
, python3Packages
|
|
|
|
|
|
|
|
# Mandatory dependencies
|
2020-10-26 08:17:14 +01:00
|
|
|
, libcap
|
2020-11-24 16:29:28 +01:00
|
|
|
, util-linux
|
2020-10-26 08:17:14 +01:00
|
|
|
, kbd
|
|
|
|
, kmod
|
|
|
|
|
2020-10-27 23:28:29 +01:00
|
|
|
# Optional dependencies
|
|
|
|
, pam
|
|
|
|
, cryptsetup
|
|
|
|
, lvm2
|
|
|
|
, audit
|
|
|
|
, acl
|
|
|
|
, lz4
|
|
|
|
, libgcrypt
|
|
|
|
, libgpgerror
|
|
|
|
, libidn2
|
|
|
|
, curl
|
|
|
|
, gnutar
|
|
|
|
, gnupg
|
|
|
|
, zlib
|
|
|
|
, xz
|
|
|
|
, libuuid
|
|
|
|
, libapparmor
|
|
|
|
, intltool
|
|
|
|
, bzip2
|
|
|
|
, pcre2
|
|
|
|
, e2fsprogs
|
2020-10-26 08:17:14 +01:00
|
|
|
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
|
|
|
|
, gnu-efi
|
|
|
|
, iptables
|
2020-10-27 23:28:29 +01:00
|
|
|
, withSelinux ? false
|
|
|
|
, libselinux
|
2021-02-25 17:21:13 +01:00
|
|
|
, withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp
|
2020-10-27 23:28:29 +01:00
|
|
|
, libseccomp
|
2021-02-25 17:21:13 +01:00
|
|
|
, withKexectools ? lib.meta.availableOn stdenv.hostPlatform kexectools
|
2020-10-27 23:28:29 +01:00
|
|
|
, kexectools
|
2020-10-26 08:17:14 +01:00
|
|
|
, bashInteractive
|
2020-11-01 18:47:18 +01:00
|
|
|
, libmicrohttpd
|
2020-10-26 08:17:14 +01:00
|
|
|
|
2020-10-28 00:29:07 +01:00
|
|
|
, withAnalyze ? true
|
2020-10-28 01:26:24 +01:00
|
|
|
, withApparmor ? true
|
2020-10-28 00:02:24 +01:00
|
|
|
, withCompression ? true # adds bzip2, lz4 and xz
|
2020-11-25 00:11:56 +01:00
|
|
|
, withCoredump ? true
|
2020-10-27 23:48:19 +01:00
|
|
|
, withCryptsetup ? true
|
2020-10-28 00:54:08 +01:00
|
|
|
, withDocumentation ? true
|
2020-10-27 23:48:19 +01:00
|
|
|
, withEfi ? stdenv.hostPlatform.isEfi
|
2020-11-25 00:11:56 +01:00
|
|
|
, withHomed ? false
|
2020-10-26 08:17:14 +01:00
|
|
|
, withHostnamed ? true
|
2020-10-27 23:48:19 +01:00
|
|
|
, withHwdb ? true
|
|
|
|
, withImportd ? true
|
2020-10-26 08:17:14 +01:00
|
|
|
, withLocaled ? true
|
2020-10-27 23:48:19 +01:00
|
|
|
, withLogind ? true
|
2020-10-28 01:08:29 +01:00
|
|
|
, withMachined ? true
|
2020-10-26 08:17:14 +01:00
|
|
|
, withNetworkd ? true
|
2020-10-28 01:05:14 +01:00
|
|
|
, withNss ? true
|
2020-11-01 15:35:11 +01:00
|
|
|
, withOomd ? false
|
2020-10-28 01:36:02 +01:00
|
|
|
, withPCRE2 ? true
|
2020-10-28 00:48:51 +01:00
|
|
|
, withPolkit ? true
|
2020-11-25 00:11:56 +01:00
|
|
|
, withPortabled ? false
|
2020-11-01 18:47:18 +01:00
|
|
|
, withRemote ? true
|
2020-10-27 23:48:19 +01:00
|
|
|
, withResolved ? true
|
2020-10-28 00:51:39 +01:00
|
|
|
, withShellCompletions ? true
|
2020-10-26 08:17:14 +01:00
|
|
|
, withTimedated ? true
|
|
|
|
, withTimesyncd ? true
|
2020-10-28 01:00:44 +01:00
|
|
|
, withUserDb ? true
|
2020-11-25 00:11:56 +01:00
|
|
|
, libfido2
|
2020-11-01 15:35:11 +01:00
|
|
|
, p11-kit
|
2020-10-26 08:17:14 +01:00
|
|
|
|
2020-10-27 23:28:29 +01:00
|
|
|
# name argument
|
2020-10-26 08:17:14 +01:00
|
|
|
, pname ? "systemd"
|
|
|
|
|
|
|
|
|
2020-10-27 23:28:29 +01:00
|
|
|
, libxslt
|
|
|
|
, docbook_xsl
|
|
|
|
, docbook_xml_dtd_42
|
|
|
|
, docbook_xml_dtd_45
|
2012-06-06 18:07:30 +02:00
|
|
|
}:
|
2012-05-21 22:48:19 +02:00
|
|
|
|
2020-10-26 08:17:14 +01:00
|
|
|
assert withResolved -> (libgcrypt != null && libgpgerror != null);
|
|
|
|
assert withImportd ->
|
2020-10-27 23:28:29 +01:00
|
|
|
(curl.dev != null && zlib != null && xz != null && libgcrypt != null
|
2020-11-25 00:11:56 +01:00
|
|
|
&& gnutar != null && gnupg != null && withCompression);
|
2020-10-26 08:17:14 +01:00
|
|
|
|
2020-10-28 00:33:26 +01:00
|
|
|
assert withEfi -> (gnu-efi != null);
|
2020-10-27 23:48:19 +01:00
|
|
|
assert withRemote -> lib.getDev curl != null;
|
2020-10-28 00:12:45 +01:00
|
|
|
assert withCoredump -> withCompression;
|
2020-10-27 23:48:19 +01:00
|
|
|
|
2020-10-10 12:05:31 +02:00
|
|
|
assert withHomed -> withCryptsetup;
|
|
|
|
|
2020-10-26 08:17:14 +01:00
|
|
|
assert withCryptsetup ->
|
2020-10-27 23:28:29 +01:00
|
|
|
(cryptsetup != null);
|
2020-08-06 12:04:28 +02:00
|
|
|
let
|
2020-10-27 23:48:19 +01:00
|
|
|
wantCurl = withRemote || withImportd;
|
|
|
|
|
2021-03-31 18:24:19 +02:00
|
|
|
version = "247.6";
|
2020-10-27 23:28:29 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
2020-10-26 08:17:14 +01:00
|
|
|
inherit version pname;
|
2018-03-03 00:31:30 +01:00
|
|
|
|
2020-08-06 12:04:28 +02:00
|
|
|
# We use systemd/systemd-stable for src, and ship NixOS-specific patches inside nixpkgs directly
|
|
|
|
# This has proven to be less error-prone than the previous systemd fork.
|
2018-03-03 00:31:30 +01:00
|
|
|
src = fetchFromGitHub {
|
2020-01-26 14:56:41 +01:00
|
|
|
owner = "systemd";
|
2020-12-13 16:35:01 +01:00
|
|
|
repo = "systemd-stable";
|
2020-08-06 12:04:28 +02:00
|
|
|
rev = "v${version}";
|
2021-03-31 18:24:19 +02:00
|
|
|
sha256 = "sha256-7XYEq3Qw25suwjbtPzx9lVPHUu9ZY/1bADXl2wQbkJc=";
|
2018-03-03 00:31:30 +01:00
|
|
|
};
|
|
|
|
|
2020-08-06 12:04:28 +02:00
|
|
|
# If these need to be regenerated, `git am path/to/00*.patch` them into a
|
|
|
|
# systemd worktree, rebase to the more recent systemd version, and export the
|
2021-03-31 18:24:19 +02:00
|
|
|
# patches again via `git -c format.signoff=false format-patch v${version}`.
|
2020-11-01 15:35:11 +01:00
|
|
|
# Use `find . -name "*.patch" | sort` to get an up-to-date listing of all patches
|
2020-01-26 14:56:41 +01:00
|
|
|
patches = [
|
|
|
|
./0001-Start-device-units-for-uninitialised-encrypted-devic.patch
|
2020-04-30 01:03:18 +02:00
|
|
|
./0002-Don-t-try-to-unmount-nix-or-nix-store.patch
|
|
|
|
./0003-Fix-NixOS-containers.patch
|
|
|
|
./0004-Look-for-fsck-in-the-right-place.patch
|
|
|
|
./0005-Add-some-NixOS-specific-unit-directories.patch
|
|
|
|
./0006-Get-rid-of-a-useless-message-in-user-sessions.patch
|
|
|
|
./0007-hostnamed-localed-timedated-disable-methods-that-cha.patch
|
|
|
|
./0008-Fix-hwdb-paths.patch
|
|
|
|
./0009-Change-usr-share-zoneinfo-to-etc-zoneinfo.patch
|
|
|
|
./0010-localectl-use-etc-X11-xkb-for-list-x11.patch
|
|
|
|
./0011-build-don-t-create-statedir-and-don-t-touch-prefixdi.patch
|
2020-11-01 15:35:11 +01:00
|
|
|
./0012-inherit-systemd-environment-when-calling-generators.patch
|
|
|
|
./0013-add-rootprefix-to-lookup-dir-paths.patch
|
|
|
|
./0014-systemd-shutdown-execute-scripts-in-etc-systemd-syst.patch
|
|
|
|
./0015-systemd-sleep-execute-scripts-in-etc-systemd-system-.patch
|
|
|
|
./0016-kmod-static-nodes.service-Update-ConditionFileNotEmp.patch
|
|
|
|
./0017-path-util.h-add-placeholder-for-DEFAULT_PATH_NORMAL.patch
|
|
|
|
./0018-logind-seat-debus-show-CanMultiSession-again.patch
|
2021-03-31 18:24:19 +02:00
|
|
|
./0019-pkg-config-derive-prefix-from-prefix.patch
|
2021-04-30 14:23:00 +02:00
|
|
|
|
|
|
|
# Fix -Werror=format.
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/systemd/systemd/commit/ab1aa6368a883bce88e3162fee2bea14aacedf23.patch";
|
|
|
|
sha256 = "1b280l5jrjsg8qhsang199mpqjhkpix4c8bm3blknjnq9iv43add";
|
|
|
|
})
|
2021-07-20 15:27:15 +02:00
|
|
|
|
|
|
|
# Fix CVE-2021-33910, disclosed 2021-07-20
|
|
|
|
(fetchpatch {
|
|
|
|
name = "CVE-2021-33910.patch";
|
|
|
|
url = "https://github.com/systemd/systemd/commit/441e0115646d54f080e5c3bb0ba477c892861ab9.patch";
|
|
|
|
sha256 = "1g1lk95igaadg67kah9bpi4zsc01rg398sd1247ghjsvl5hxn4v4";
|
|
|
|
})
|
2020-01-26 14:56:41 +01:00
|
|
|
];
|
|
|
|
|
2020-03-07 23:47:22 +01:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace src/basic/path-util.h --replace "@defaultPathNormal@" "${placeholder "out"}/bin/"
|
2020-06-08 02:25:01 +02:00
|
|
|
substituteInPlace src/boot/efi/meson.build \
|
|
|
|
--replace \
|
|
|
|
"find_program('ld'" \
|
|
|
|
"find_program('${stdenv.cc.bintools.targetPrefix}ld'" \
|
|
|
|
--replace \
|
|
|
|
"find_program('objcopy'" \
|
|
|
|
"find_program('${stdenv.cc.bintools.targetPrefix}objcopy'"
|
2021-02-03 18:54:07 +01:00
|
|
|
'' + (
|
|
|
|
let
|
|
|
|
# The folllowing dlopen patches ensure that all the features that are
|
|
|
|
# implemented via dlopen(3) are available (or explicitly deactivated) by
|
|
|
|
# pointing dlopen to the absolute store path instead of relying on the
|
|
|
|
# linkers runtime lookup code.
|
|
|
|
#
|
|
|
|
# All of the dlopen calls have to be handled. When new ones are introduced
|
|
|
|
# by upstream (or one of our patches) they must be explicitly declared,
|
|
|
|
# otherwise the build will fail.
|
|
|
|
#
|
|
|
|
# As of systemd version 247 we've seen a few errors like `libpcre2.… not
|
|
|
|
# found` when using e.g. --grep with journalctl. Those errors should
|
|
|
|
# become less unexpected now.
|
|
|
|
#
|
|
|
|
# There are generally two classes of dlopen(3) calls. Those that we want to
|
|
|
|
# support and those that should be deactivated / unsupported. This change
|
|
|
|
# enforces that we handle all dlopen calls explicitly. Meaning: There is
|
|
|
|
# not a single dlopen call in the source code tree that we did not
|
|
|
|
# explicitly handle.
|
|
|
|
#
|
|
|
|
# In order to do this we introduced a list of attributes that maps from
|
|
|
|
# shared object name to the package that contains them. The package can be
|
|
|
|
# null meaning the reference should be nuked and the shared object will
|
|
|
|
# never be loadable during runtime (because it points at an invalid store
|
|
|
|
# path location).
|
|
|
|
#
|
|
|
|
# To get a list of dynamically loaded libraries issue something like
|
|
|
|
# `grep -ri 'dlopen("lib' $src` and update the below list.
|
|
|
|
dlopenLibs = [
|
|
|
|
# We did never provide support for libxkbcommon & qrencode
|
|
|
|
{ name = "libxkbcommon.so.0"; pkg = null; }
|
|
|
|
{ name = "libqrencode.so.4"; pkg = null; }
|
2020-12-26 16:55:33 +01:00
|
|
|
|
2021-02-03 18:54:07 +01:00
|
|
|
# We did not provide libpwquality before so it is safe to disable it for
|
|
|
|
# now.
|
|
|
|
{ name = "libpwquality.so.1"; pkg = null; }
|
2020-12-26 16:55:33 +01:00
|
|
|
|
2021-02-03 18:54:07 +01:00
|
|
|
# Only include cryptsetup if it is enabled. We might not be able to
|
|
|
|
# provide it during "bootstrap" in e.g. the minimal systemd build as
|
|
|
|
# cryptsetup has udev (aka systemd) in it's dependencies.
|
|
|
|
{ name = "libcryptsetup.so.12"; pkg = if withCryptsetup then cryptsetup else null; }
|
2020-12-26 16:55:33 +01:00
|
|
|
|
2021-02-03 18:54:07 +01:00
|
|
|
# We are using libidn2 so we only provide that and ignore the others.
|
|
|
|
# Systemd does this decision during configure time and uses ifdef's to
|
|
|
|
# enable specific branches. We can safely ignore (nuke) the libidn "v1"
|
|
|
|
# libraries.
|
|
|
|
{ name = "libidn2.so.0"; pkg = libidn2; }
|
|
|
|
{ name = "libidn.so.12"; pkg = null; }
|
|
|
|
{ name = "libidn.so.11"; pkg = null; }
|
2020-12-26 16:55:33 +01:00
|
|
|
|
2021-02-03 18:54:07 +01:00
|
|
|
# journalctl --grep requires libpcre so lets provide it
|
|
|
|
{ name = "libpcre2-8.so.0"; pkg = pcre2; }
|
|
|
|
];
|
2020-12-26 16:55:33 +01:00
|
|
|
|
2021-02-03 18:54:07 +01:00
|
|
|
patchDlOpen = dl:
|
|
|
|
let
|
|
|
|
library = "${lib.makeLibraryPath [ dl.pkg ]}/${dl.name}";
|
|
|
|
in
|
|
|
|
if dl.pkg == null then ''
|
|
|
|
# remove the dependency on the library by replacing it with an invalid path
|
|
|
|
for file in $(grep -lr 'dlopen("${dl.name}"' src); do
|
|
|
|
echo "patching dlopen(\"${dl.name}\", …) in $file to an invalid store path ("/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-not-implemented/${dl.name}")…"
|
|
|
|
substituteInPlace "$file" --replace 'dlopen("${dl.name}"' 'dlopen("/nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-not-implemented/${dl.name}"'
|
|
|
|
done
|
|
|
|
'' else ''
|
|
|
|
# ensure that the library we provide actually exists
|
|
|
|
if ! [ -e ${library} ]; then
|
|
|
|
echo 'The shared library `${library}` does not exist but was given as subtitute for `${dl.name}`'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# make the path to the dependency explicit
|
|
|
|
for file in $(grep -lr 'dlopen("${dl.name}"' src); do
|
|
|
|
echo "patching dlopen(\"${dl.name}\", …) in $file to ${library}…"
|
|
|
|
substituteInPlace "$file" --replace 'dlopen("${dl.name}"' 'dlopen("${library}"'
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
# patch all the dlopen calls to contain absolute paths to the libraries
|
|
|
|
lib.concatMapStringsSep "\n" patchDlOpen dlopenLibs
|
|
|
|
)
|
2020-12-26 16:55:33 +01:00
|
|
|
# finally ensure that there are no left-over dlopen calls that we didn't handle
|
|
|
|
+ ''
|
|
|
|
if grep -qr 'dlopen("[^/]' src; then
|
|
|
|
echo "Found unhandled dlopen calls: "
|
|
|
|
grep -r 'dlopen("[^/]' src
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-03-07 23:47:22 +01:00
|
|
|
'';
|
|
|
|
|
2020-08-12 18:34:09 +02:00
|
|
|
outputs = [ "out" "man" "dev" ];
|
2018-03-03 00:31:30 +01:00
|
|
|
|
|
|
|
nativeBuildInputs =
|
2020-10-27 23:28:29 +01:00
|
|
|
[
|
2021-01-19 07:50:56 +01:00
|
|
|
pkg-config
|
2020-10-27 23:28:29 +01:00
|
|
|
gperf
|
|
|
|
ninja
|
|
|
|
meson
|
2018-03-03 00:31:30 +01:00
|
|
|
coreutils # meson calls date, stat etc.
|
2018-03-10 15:41:34 +01:00
|
|
|
glibcLocales
|
2020-10-27 23:28:29 +01:00
|
|
|
patchelf
|
|
|
|
getent
|
|
|
|
m4
|
2019-02-22 09:23:48 +01:00
|
|
|
|
2020-10-26 08:17:14 +01:00
|
|
|
intltool
|
|
|
|
gettext
|
|
|
|
|
2020-10-27 23:28:29 +01:00
|
|
|
libxslt
|
|
|
|
docbook_xsl
|
|
|
|
docbook_xml_dtd_42
|
|
|
|
docbook_xml_dtd_45
|
|
|
|
(buildPackages.python3Packages.python.withPackages (ps: with ps; [ python3Packages.lxml ]))
|
2018-03-03 00:31:30 +01:00
|
|
|
];
|
2020-10-27 23:28:29 +01:00
|
|
|
|
2018-03-03 00:31:30 +01:00
|
|
|
buildInputs =
|
2020-10-27 23:28:29 +01:00
|
|
|
[
|
|
|
|
acl
|
|
|
|
audit
|
|
|
|
glib
|
|
|
|
kmod
|
|
|
|
libcap
|
|
|
|
libgcrypt
|
|
|
|
libidn2
|
|
|
|
libuuid
|
|
|
|
linuxHeaders
|
|
|
|
pam
|
2020-10-27 23:37:01 +01:00
|
|
|
]
|
2020-10-28 01:36:02 +01:00
|
|
|
|
2020-11-25 00:11:56 +01:00
|
|
|
++ lib.optional withApparmor libapparmor
|
|
|
|
++ lib.optional wantCurl (lib.getDev curl)
|
2020-10-28 00:02:24 +01:00
|
|
|
++ lib.optionals withCompression [ bzip2 lz4 xz ]
|
2020-11-25 00:11:56 +01:00
|
|
|
++ lib.optional withCryptsetup (lib.getDev cryptsetup.dev)
|
|
|
|
++ lib.optional withEfi gnu-efi
|
|
|
|
++ lib.optional withKexectools kexectools
|
|
|
|
++ lib.optional withLibseccomp libseccomp
|
|
|
|
++ lib.optional withNetworkd iptables
|
|
|
|
++ lib.optional withPCRE2 pcre2
|
|
|
|
++ lib.optional withResolved libgpgerror
|
|
|
|
++ lib.optional withSelinux libselinux
|
|
|
|
++ lib.optional withRemote libmicrohttpd
|
2020-10-10 12:05:31 +02:00
|
|
|
++ lib.optionals withHomed [ p11-kit libfido2 ]
|
2020-11-25 00:11:56 +01:00
|
|
|
;
|
2018-03-03 00:31:30 +01:00
|
|
|
|
|
|
|
#dontAddPrefix = true;
|
|
|
|
|
|
|
|
mesonFlags = [
|
2019-09-16 04:51:15 +02:00
|
|
|
"-Ddbuspolicydir=${placeholder "out"}/share/dbus-1/system.d"
|
2019-02-22 09:23:48 +01:00
|
|
|
"-Ddbussessionservicedir=${placeholder "out"}/share/dbus-1/services"
|
|
|
|
"-Ddbussystemservicedir=${placeholder "out"}/share/dbus-1/system-services"
|
|
|
|
"-Dpamconfdir=${placeholder "out"}/etc/pam.d"
|
|
|
|
"-Drootprefix=${placeholder "out"}"
|
|
|
|
"-Dpkgconfiglibdir=${placeholder "dev"}/lib/pkgconfig"
|
|
|
|
"-Dpkgconfigdatadir=${placeholder "dev"}/share/pkgconfig"
|
2018-03-03 00:31:30 +01:00
|
|
|
"-Dloadkeys-path=${kbd}/bin/loadkeys"
|
|
|
|
"-Dsetfont-path=${kbd}/bin/setfont"
|
|
|
|
"-Dtty-gid=3" # tty in NixOS has gid 3
|
2017-03-31 07:34:55 +02:00
|
|
|
"-Ddebug-shell=${bashInteractive}/bin/bash"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dglib=${lib.boolToString (glib != null)}"
|
2019-05-17 20:00:22 +02:00
|
|
|
# while we do not run tests we should also not build them. Removes about 600 targets
|
|
|
|
"-Dtests=false"
|
2020-10-28 00:29:07 +01:00
|
|
|
"-Danalyze=${lib.boolToString withAnalyze}"
|
2020-10-28 00:29:34 +01:00
|
|
|
"-Dgcrypt=${lib.boolToString (libgcrypt != null)}"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dimportd=${lib.boolToString withImportd}"
|
2020-10-28 00:02:24 +01:00
|
|
|
"-Dlz4=${lib.boolToString withCompression}"
|
2021-01-15 15:45:37 +01:00
|
|
|
"-Dhomed=${lib.boolToString withHomed}"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dlogind=${lib.boolToString withLogind}"
|
|
|
|
"-Dlocaled=${lib.boolToString withLocaled}"
|
|
|
|
"-Dhostnamed=${lib.boolToString withHostnamed}"
|
2020-10-28 01:08:29 +01:00
|
|
|
"-Dmachined=${lib.boolToString withMachined}"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dnetworkd=${lib.boolToString withNetworkd}"
|
2020-11-01 15:35:11 +01:00
|
|
|
"-Doomd=${lib.boolToString withOomd}"
|
2020-10-28 00:48:51 +01:00
|
|
|
"-Dpolkit=${lib.boolToString withPolkit}"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dcryptsetup=${lib.boolToString withCryptsetup}"
|
2020-11-25 00:11:56 +01:00
|
|
|
"-Dportabled=${lib.boolToString withPortabled}"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dhwdb=${lib.boolToString withHwdb}"
|
2020-10-27 23:48:19 +01:00
|
|
|
"-Dremote=${lib.boolToString withRemote}"
|
2018-03-03 00:31:30 +01:00
|
|
|
"-Dsysusers=false"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dtimedated=${lib.boolToString withTimedated}"
|
|
|
|
"-Dtimesyncd=${lib.boolToString withTimesyncd}"
|
2020-10-28 01:00:44 +01:00
|
|
|
"-Duserdb=${lib.boolToString withUserDb}"
|
2020-10-28 00:12:45 +01:00
|
|
|
"-Dcoredump=${lib.boolToString withCoredump}"
|
2018-03-03 00:31:30 +01:00
|
|
|
"-Dfirstboot=false"
|
2020-10-27 23:20:54 +01:00
|
|
|
"-Dresolve=${lib.boolToString withResolved}"
|
2018-03-03 00:31:30 +01:00
|
|
|
"-Dsplit-usr=false"
|
2020-10-27 23:48:19 +01:00
|
|
|
"-Dlibcurl=${lib.boolToString wantCurl}"
|
2018-03-03 00:31:30 +01:00
|
|
|
"-Dlibidn=false"
|
|
|
|
"-Dlibidn2=true"
|
|
|
|
"-Dquotacheck=false"
|
|
|
|
"-Dldconfig=false"
|
|
|
|
"-Dsmack=true"
|
2019-02-22 09:23:48 +01:00
|
|
|
"-Db_pie=true"
|
2020-11-01 15:35:11 +01:00
|
|
|
"-Dinstall-sysconfdir=false"
|
2019-07-31 23:19:49 +02:00
|
|
|
/*
|
|
|
|
As of now, systemd doesn't allow runtime configuration of these values. So
|
|
|
|
the settings in /etc/login.defs have no effect on it. Many people think this
|
|
|
|
should be supported however, see
|
|
|
|
- https://github.com/systemd/systemd/issues/3855
|
|
|
|
- https://github.com/systemd/systemd/issues/4850
|
|
|
|
- https://github.com/systemd/systemd/issues/9769
|
|
|
|
- https://github.com/systemd/systemd/issues/9843
|
|
|
|
- https://github.com/systemd/systemd/issues/10184
|
|
|
|
*/
|
|
|
|
"-Dsystem-uid-max=999"
|
|
|
|
"-Dsystem-gid-max=999"
|
2018-03-03 00:31:30 +01:00
|
|
|
# "-Dtime-epoch=1"
|
|
|
|
|
|
|
|
"-Dsysvinit-path="
|
|
|
|
"-Dsysvrcnd-path="
|
2018-03-10 15:41:34 +01:00
|
|
|
|
|
|
|
"-Dkill-path=${coreutils}/bin/kill"
|
|
|
|
"-Dkmod-path=${kmod}/bin/kmod"
|
2020-11-24 16:29:28 +01:00
|
|
|
"-Dsulogin-path=${util-linux}/bin/sulogin"
|
|
|
|
"-Dmount-path=${util-linux}/bin/mount"
|
|
|
|
"-Dumount-path=${util-linux}/bin/umount"
|
2019-09-04 01:35:49 +02:00
|
|
|
"-Dcreate-log-dirs=false"
|
2020-11-17 21:54:26 +01:00
|
|
|
|
|
|
|
# Use cgroupsv2. This is already the upstream default, but better be explicit.
|
|
|
|
"-Ddefault-hierarchy=unified"
|
2019-09-04 01:35:49 +02:00
|
|
|
# Upstream defaulted to disable manpages since they optimize for the much
|
|
|
|
# more frequent development builds
|
|
|
|
"-Dman=true"
|
2020-10-26 08:17:14 +01:00
|
|
|
|
2020-10-28 00:35:00 +01:00
|
|
|
"-Defi=${lib.boolToString withEfi}"
|
2020-10-28 00:33:26 +01:00
|
|
|
"-Dgnu-efi=${lib.boolToString withEfi}"
|
|
|
|
] ++ lib.optionals withEfi [
|
2020-10-26 08:17:14 +01:00
|
|
|
"-Defi-libdir=${toString gnu-efi}/lib"
|
|
|
|
"-Defi-includedir=${toString gnu-efi}/include/efi"
|
|
|
|
"-Defi-ldsdir=${toString gnu-efi}/lib"
|
2020-10-28 00:51:39 +01:00
|
|
|
] ++ lib.optionals (withShellCompletions == false) [
|
|
|
|
"-Dbashcompletiondir=no"
|
|
|
|
"-Dzshcompletiondir=no"
|
2020-10-28 01:05:14 +01:00
|
|
|
] ++ lib.optionals (!withNss) [
|
|
|
|
"-Dnss-myhostname=false"
|
|
|
|
"-Dnss-mymachines=false"
|
|
|
|
"-Dnss-resolve=false"
|
|
|
|
"-Dnss-systemd=false"
|
2018-03-03 00:31:30 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
mesonFlagsArray+=(-Dntp-servers="0.nixos.pool.ntp.org 1.nixos.pool.ntp.org 2.nixos.pool.ntp.org 3.nixos.pool.ntp.org")
|
|
|
|
export LC_ALL="en_US.UTF-8";
|
|
|
|
# FIXME: patch this in systemd properly (and send upstream).
|
|
|
|
# already fixed in f00929ad622c978f8ad83590a15a765b4beecac9: (u)mount
|
2019-05-14 01:20:56 +02:00
|
|
|
for i in \
|
|
|
|
src/core/mount.c \
|
|
|
|
src/core/swap.c \
|
|
|
|
src/cryptsetup/cryptsetup-generator.c \
|
|
|
|
src/journal/cat.c \
|
|
|
|
src/nspawn/nspawn.c \
|
|
|
|
src/remount-fs/remount-fs.c \
|
|
|
|
src/shared/generator.c \
|
|
|
|
src/shutdown/shutdown.c \
|
|
|
|
units/emergency.service.in \
|
2021-03-09 17:41:02 +01:00
|
|
|
units/modprobe@.service \
|
2019-05-14 01:20:56 +02:00
|
|
|
units/rescue.service.in \
|
|
|
|
units/systemd-logind.service.in \
|
|
|
|
units/systemd-nspawn@.service.in; \
|
|
|
|
do
|
2018-03-03 00:31:30 +01:00
|
|
|
test -e $i
|
|
|
|
substituteInPlace $i \
|
|
|
|
--replace /usr/bin/getent ${getent}/bin/getent \
|
2020-11-24 16:29:28 +01:00
|
|
|
--replace /sbin/mkswap ${lib.getBin util-linux}/sbin/mkswap \
|
|
|
|
--replace /sbin/swapon ${lib.getBin util-linux}/sbin/swapon \
|
|
|
|
--replace /sbin/swapoff ${lib.getBin util-linux}/sbin/swapoff \
|
2018-03-03 00:31:30 +01:00
|
|
|
--replace /bin/echo ${coreutils}/bin/echo \
|
|
|
|
--replace /bin/cat ${coreutils}/bin/cat \
|
2020-11-24 16:29:28 +01:00
|
|
|
--replace /sbin/sulogin ${lib.getBin util-linux}/sbin/sulogin \
|
2019-10-05 19:25:43 +02:00
|
|
|
--replace /sbin/modprobe ${lib.getBin kmod}/sbin/modprobe \
|
2018-03-03 00:31:30 +01:00
|
|
|
--replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \
|
|
|
|
--replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
|
|
|
|
done
|
|
|
|
|
2020-11-01 15:35:11 +01:00
|
|
|
for dir in tools src/resolve test src/test src/shared; do
|
2019-02-22 09:23:48 +01:00
|
|
|
patchShebangs $dir
|
2018-03-03 00:31:30 +01:00
|
|
|
done
|
|
|
|
|
2019-10-03 22:24:15 +02:00
|
|
|
# absolute paths to gpg & tar
|
|
|
|
substituteInPlace src/import/pull-common.c \
|
2020-08-06 12:01:45 +02:00
|
|
|
--replace '"gpg"' '"${gnupg}/bin/gpg"'
|
2019-10-03 22:24:15 +02:00
|
|
|
for file in src/import/{{export,import,pull}-tar,import-common}.c; do
|
|
|
|
substituteInPlace $file \
|
|
|
|
--replace '"tar"' '"${gnutar}/bin/tar"'
|
|
|
|
done
|
|
|
|
|
2018-03-03 00:31:30 +01:00
|
|
|
substituteInPlace src/journal/catalog.c \
|
|
|
|
--replace /usr/lib/systemd/catalog/ $out/lib/systemd/catalog/
|
|
|
|
'';
|
|
|
|
|
|
|
|
# These defines are overridden by CFLAGS and would trigger annoying
|
|
|
|
# warning messages
|
|
|
|
postConfigure = ''
|
|
|
|
substituteInPlace config.h \
|
|
|
|
--replace "POLKIT_AGENT_BINARY_PATH" "_POLKIT_AGENT_BINARY_PATH" \
|
|
|
|
--replace "SYSTEMD_BINARY_PATH" "_SYSTEMD_BINARY_PATH" \
|
|
|
|
--replace "SYSTEMD_CGROUP_AGENT_PATH" "_SYSTEMD_CGROUP_AGENT_PATH"
|
|
|
|
'';
|
|
|
|
|
2019-10-30 00:53:51 +01:00
|
|
|
NIX_CFLAGS_COMPILE = toString [
|
|
|
|
# Can't say ${polkit.bin}/bin/pkttyagent here because that would
|
|
|
|
# lead to a cyclic dependency.
|
2020-10-27 23:28:29 +01:00
|
|
|
"-UPOLKIT_AGENT_BINARY_PATH"
|
|
|
|
"-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\""
|
2018-03-03 00:31:30 +01:00
|
|
|
|
2019-10-30 00:53:51 +01:00
|
|
|
# Set the release_agent on /sys/fs/cgroup/systemd to the
|
|
|
|
# currently running systemd (/run/current-system/systemd) so
|
|
|
|
# that we don't use an obsolete/garbage-collected release agent.
|
2020-10-27 23:28:29 +01:00
|
|
|
"-USYSTEMD_CGROUP_AGENT_PATH"
|
|
|
|
"-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\""
|
2018-03-03 00:31:30 +01:00
|
|
|
|
2020-10-27 23:28:29 +01:00
|
|
|
"-USYSTEMD_BINARY_PATH"
|
|
|
|
"-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\""
|
2019-10-30 00:53:51 +01:00
|
|
|
];
|
2018-03-03 00:31:30 +01:00
|
|
|
|
2018-04-25 05:20:18 +02:00
|
|
|
doCheck = false; # fails a bunch of tests
|
|
|
|
|
2020-01-26 16:15:19 +01:00
|
|
|
# trigger the test -n "$DESTDIR" || mutate in upstreams build system
|
|
|
|
preInstall = ''
|
|
|
|
export DESTDIR=/
|
|
|
|
'';
|
|
|
|
|
2018-03-03 00:31:30 +01:00
|
|
|
postInstall = ''
|
|
|
|
# sysinit.target: Don't depend on
|
|
|
|
# systemd-tmpfiles-setup.service. This interferes with NixOps's
|
|
|
|
# send-keys feature (since sshd.service depends indirectly on
|
|
|
|
# sysinit.target).
|
|
|
|
mv $out/lib/systemd/system/sysinit.target.wants/systemd-tmpfiles-setup-dev.service $out/lib/systemd/system/multi-user.target.wants/
|
|
|
|
|
|
|
|
mkdir -p $out/example/systemd
|
|
|
|
mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example
|
|
|
|
mv $out/lib/systemd/{system,user} $out/example/systemd
|
|
|
|
|
|
|
|
rm -rf $out/etc/systemd/system
|
|
|
|
|
|
|
|
# Fix reference to /bin/false in the D-Bus services.
|
|
|
|
for i in $out/share/dbus-1/system-services/*.service; do
|
|
|
|
substituteInPlace $i --replace /bin/false ${coreutils}/bin/false
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -rf $out/etc/rpm
|
|
|
|
|
|
|
|
# "kernel-install" shouldn't be used on NixOS.
|
|
|
|
find $out -name "*kernel-install*" -exec rm {} \;
|
2020-10-28 00:54:08 +01:00
|
|
|
'' + lib.optionalString (!withDocumentation) ''
|
|
|
|
rm -rf $out/share/doc
|
|
|
|
'';
|
2018-03-03 00:31:30 +01:00
|
|
|
|
|
|
|
# The interface version prevents NixOS from switching to an
|
|
|
|
# incompatible systemd at runtime. (Switching across reboots is
|
|
|
|
# fine, of course.) It should be increased whenever systemd changes
|
|
|
|
# in a backwards-incompatible way. If the interface version of two
|
|
|
|
# systemd builds is the same, then we can switch between them at
|
|
|
|
# runtime; otherwise we can't and we need to reboot.
|
2019-09-16 16:51:19 +02:00
|
|
|
passthru.interfaceVersion = 2;
|
2018-03-03 00:31:30 +01:00
|
|
|
|
2020-10-27 23:20:54 +01:00
|
|
|
meta = with lib; {
|
2020-02-18 21:46:40 +01:00
|
|
|
homepage = "https://www.freedesktop.org/wiki/Software/systemd/";
|
2018-03-03 00:31:30 +01:00
|
|
|
description = "A system and service manager for Linux";
|
2018-08-18 00:32:36 +02:00
|
|
|
license = licenses.lgpl21Plus;
|
|
|
|
platforms = platforms.linux;
|
2019-05-08 12:55:25 +02:00
|
|
|
priority = 10;
|
2020-10-26 08:17:14 +01:00
|
|
|
maintainers = with maintainers; [ andir eelco flokli kloenk ];
|
2018-03-03 00:31:30 +01:00
|
|
|
};
|
2012-05-21 22:48:19 +02:00
|
|
|
}
|