Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c6bbc94
systemd: stdenv.lib -> lib
flokli Oct 27, 2020
229184f
systemd: reorder buildInputs
flokli Oct 27, 2020
6456e24
systemd: nixpkgs-fmt
flokli Oct 27, 2020
8434da5
systemd: remove perl from nativeBuildInputs
flokli Oct 27, 2020
39e7333
systemd: build without iptables when networkd is disabled
flokli Oct 27, 2020
e1e01fa
systemd: add withRemote option (default to false), make curl optional
flokli Oct 27, 2020
5f257d7
systemd: cleanup cryptsetup input
flokli Oct 27, 2020
ff07c6b
systemd: introduce withCompression flag
flokli Oct 27, 2020
c6aada2
systemd: drop duplicate -Dlocaled=…
flokli Oct 27, 2020
8d18be9
systemdMinimal: sort feature flags
flokli Oct 27, 2020
b027cf2
systemdMinimal: disable networkd
flokli Oct 27, 2020
987906a
systemd: add withCoredump flag
flokli Oct 27, 2020
585f4a1
systemd: add withAnalyze flag
flokli Oct 27, 2020
13a910e
systemd: make gcrypt optional
flokli Oct 27, 2020
54c35f0
systemd: withEfi: move gnu-efi check into assertion
flokli Oct 27, 2020
0b762c0
systemd: disable efi if we don't build with withEfi is set to false
flokli Oct 27, 2020
1f93474
systemd: add withPolkit option
flokli Oct 27, 2020
f142493
systemd: add withShellCompletions flag
flokli Oct 27, 2020
e773262
systemd: add withDocumentation flag
flokli Oct 27, 2020
a079a6f
systemd: add withUserDb flag
flokli Oct 28, 2020
8526662
systemd: add withNss flag
flokli Oct 28, 2020
e10a9a8
systemd: add withMachined flag
flokli Oct 28, 2020
961663a
systemdMinimal: disable timesyncd
flokli Oct 28, 2020
e6dff1d
systemd: drop libffi from buildInputs
flokli Oct 28, 2020
065f057
systemd: add libgpgerror only to buildInputs if we build with resolve…
flokli Oct 28, 2020
93dcbbf
systemd: add withApparmor option
flokli Oct 28, 2020
959cea2
systemd: add withPCRE2 option
flokli Oct 28, 2020
6dbc23e
systemd: stop substituting inside fsck.c, stop substituting mke2fs
flokli Oct 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 159 additions & 69 deletions pkgs/os-specific/linux/systemd/default.nix
Original file line number Diff line number Diff line change
@@ -1,60 +1,110 @@
{ stdenv, lib, fetchFromGitHub
{ stdenv
, lib
, fetchFromGitHub
, buildPackages
, ninja, meson, m4, pkgconfig, coreutils, gperf, getent
, patchelf, perl, glibcLocales, glib, substituteAll
, gettext, python3Packages

# Mandatory dependencies
, ninja
, meson
, m4
, pkgconfig
, coreutils
, gperf
, getent
, patchelf
, glibcLocales
, glib
, substituteAll
, gettext
, python3Packages

# Mandatory dependencies
, libcap
, utillinux
, kbd
, kmod

# Optional dependencies
, pam, cryptsetup, lvm2, audit, acl
, lz4, libgcrypt, libgpgerror, libidn2
, curl, gnutar, gnupg, zlib
, xz, libuuid, libffi
, libapparmor, intltool
, bzip2, pcre2, e2fsprogs
# Optional dependencies
, pam
, cryptsetup
, lvm2
, audit
, acl
, lz4
, libgcrypt
, libgpgerror
, libidn2
, curl
, gnutar
, gnupg
, zlib
, xz
, libuuid
, libapparmor
, intltool
, bzip2
, pcre2
, e2fsprogs
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
, gnu-efi
, iptables
, withSelinux ? false, libselinux
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
, withKexectools ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) kexectools.meta.platforms, kexectools
, withSelinux ? false
, libselinux
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms
, libseccomp
, withKexectools ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) kexectools.meta.platforms
, kexectools
, bashInteractive

, withResolved ? true
, withLogind ? true
, withAnalyze ? true
, withApparmor ? true
, withCoredump ? true
, withCompression ? true # adds bzip2, lz4 and xz
, withCryptsetup ? true
, withDocumentation ? true
, withEfi ? stdenv.hostPlatform.isEfi
, withHostnamed ? true
, withHwdb ? true
, withImportd ? true
, withLocaled ? true
, withLogind ? true
, withMachined ? true
, withNetworkd ? true
, withNss ? true
, withPCRE2 ? true
, withPolkit ? true
, withRemote ? false # has always been disabled on NixOS, upstream version appears broken anyway
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 20.03, the systemd-journal-gatewayd feature was working fine and we have an option in the NixOS module to enable it. Note the systemd-journal-gatewayd is turned off when the REMOTE option is false.
So, i think we should enable it by default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with enabling more features here, if we disable it in systemdMinimal and have tests ensuring its functionality :-)

, withResolved ? true
, withShellCompletions ? true
, withTimedated ? true
, withTimesyncd ? true
, withHwdb ? true
, withEfi ? stdenv.hostPlatform.isEfi
, withImportd ? true
, withCryptsetup ? true
, withUserDb ? true

# name argument
# name argument
, pname ? "systemd"


, libxslt, docbook_xsl, docbook_xml_dtd_42, docbook_xml_dtd_45
, libxslt
, docbook_xsl
, docbook_xml_dtd_42
, docbook_xml_dtd_45
}:

assert withResolved -> (libgcrypt != null && libgpgerror != null);
assert withImportd ->
( curl.dev != null && zlib != null && xz != null && libgcrypt != null
&& gnutar != null && gnupg != null);
(curl.dev != null && zlib != null && xz != null && libgcrypt != null
&& gnutar != null && gnupg != null && withCompression );

assert withCryptsetup ->
( cryptsetup != null );
assert withEfi -> (gnu-efi != null);
assert withRemote -> lib.getDev curl != null;
assert withCoredump -> withCompression;

assert withCryptsetup ->
(cryptsetup != null);
let
wantCurl = withRemote || withImportd;

version = "246.6";
in stdenv.mkDerivation {
in
stdenv.mkDerivation {
inherit version pname;

# We use systemd/systemd-stable for src, and ship NixOS-specific patches inside nixpkgs directly
Expand Down Expand Up @@ -105,29 +155,53 @@ in stdenv.mkDerivation {
outputs = [ "out" "man" "dev" ];

nativeBuildInputs =
[ pkgconfig gperf
ninja meson
[
pkgconfig
gperf
ninja
meson
coreutils # meson calls date, stat etc.
glibcLocales
patchelf getent m4
perl # to patch the libsystemd.so and remove dependencies on aarch64
patchelf
getent
m4

intltool
gettext

libxslt docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
(buildPackages.python3Packages.python.withPackages ( ps: with ps; [ python3Packages.lxml ]))
libxslt
docbook_xsl
docbook_xml_dtd_42
docbook_xml_dtd_45
(buildPackages.python3Packages.python.withPackages (ps: with ps; [ python3Packages.lxml ]))
];

buildInputs =
[ linuxHeaders libcap curl.dev kmod xz pam acl
cryptsetup libuuid glib libgcrypt libgpgerror libidn2
pcre2 ] ++
stdenv.lib.optional withKexectools kexectools ++
stdenv.lib.optional withLibseccomp libseccomp ++
[ libffi audit lz4 bzip2 libapparmor iptables ] ++
stdenv.lib.optional withEfi gnu-efi ++
stdenv.lib.optional withSelinux libselinux ++
stdenv.lib.optional withCryptsetup cryptsetup.dev;
[
acl
audit
glib
kmod
libcap
libgcrypt
libidn2
libuuid
linuxHeaders
pam
]

++ lib.optional withApparmor libapparmor
++ lib.optional wantCurl (lib.getDev curl)
++ lib.optionals withCompression [ bzip2 lz4 xz ]
++ 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
;

#dontAddPrefix = true;

Expand All @@ -143,28 +217,33 @@ in stdenv.mkDerivation {
"-Dsetfont-path=${kbd}/bin/setfont"
"-Dtty-gid=3" # tty in NixOS has gid 3
"-Ddebug-shell=${bashInteractive}/bin/bash"
"-Dglib=${stdenv.lib.boolToString (glib != null)}"
"-Dglib=${lib.boolToString (glib != null)}"
# while we do not run tests we should also not build them. Removes about 600 targets
"-Dtests=false"
"-Dimportd=${stdenv.lib.boolToString withImportd}"
"-Dlz4=true"
"-Danalyze=${lib.boolToString withAnalyze}"
"-Dgcrypt=${lib.boolToString (libgcrypt != null)}"
"-Dimportd=${lib.boolToString withImportd}"
"-Dlz4=${lib.boolToString withCompression}"
"-Dhomed=false"
"-Dlogind=${stdenv.lib.boolToString withLogind}"
"-Dlocaled=${stdenv.lib.boolToString withLocaled}"
"-Dhostnamed=${stdenv.lib.boolToString withHostnamed}"
"-Dnetworkd=${stdenv.lib.boolToString withNetworkd}"
"-Dcryptsetup=${stdenv.lib.boolToString withCryptsetup}"
"-Dlogind=${lib.boolToString withLogind}"
"-Dlocaled=${lib.boolToString withLocaled}"
"-Dhostnamed=${lib.boolToString withHostnamed}"
"-Dmachined=${lib.boolToString withMachined}"
"-Dnetworkd=${lib.boolToString withNetworkd}"
"-Dpolkit=${lib.boolToString withPolkit}"
"-Dcryptsetup=${lib.boolToString withCryptsetup}"
"-Dportabled=false"
"-Dhwdb=${stdenv.lib.boolToString withHwdb}"
"-Dremote=false"
"-Dhwdb=${lib.boolToString withHwdb}"
"-Dremote=${lib.boolToString withRemote}"
"-Dsysusers=false"
"-Dtimedated=${stdenv.lib.boolToString withTimedated}"
"-Dtimesyncd=${stdenv.lib.boolToString withTimesyncd}"
"-Dtimedated=${lib.boolToString withTimedated}"
"-Dtimesyncd=${lib.boolToString withTimesyncd}"
"-Duserdb=${lib.boolToString withUserDb}"
"-Dcoredump=${lib.boolToString withCoredump}"
"-Dfirstboot=false"
"-Dlocaled=true"
"-Dresolve=${stdenv.lib.boolToString withResolved}"
"-Dresolve=${lib.boolToString withResolved}"
"-Dsplit-usr=false"
"-Dlibcurl=true"
"-Dlibcurl=${lib.boolToString wantCurl}"
"-Dlibidn=false"
"-Dlibidn2=true"
"-Dquotacheck=false"
Expand Down Expand Up @@ -201,11 +280,20 @@ in stdenv.mkDerivation {
# more frequent development builds
"-Dman=true"

"-Dgnu-efi=${stdenv.lib.boolToString (withEfi && gnu-efi != null)}"
] ++ stdenv.lib.optionals (withEfi && gnu-efi != null) [
"-Defi=${lib.boolToString withEfi}"
"-Dgnu-efi=${lib.boolToString withEfi}"
] ++ lib.optionals withEfi [
"-Defi-libdir=${toString gnu-efi}/lib"
"-Defi-includedir=${toString gnu-efi}/include/efi"
"-Defi-ldsdir=${toString gnu-efi}/lib"
] ++ lib.optionals (withShellCompletions == false) [
"-Dbashcompletiondir=no"
"-Dzshcompletiondir=no"
] ++ lib.optionals (!withNss) [
"-Dnss-myhostname=false"
"-Dnss-mymachines=false"
"-Dnss-resolve=false"
"-Dnss-systemd=false"
];

preConfigure = ''
Expand All @@ -217,7 +305,6 @@ in stdenv.mkDerivation {
src/core/mount.c \
src/core/swap.c \
src/cryptsetup/cryptsetup-generator.c \
src/fsck/fsck.c \
src/journal/cat.c \
src/nspawn/nspawn.c \
src/remount-fs/remount-fs.c \
Expand All @@ -234,8 +321,6 @@ in stdenv.mkDerivation {
--replace /sbin/mkswap ${lib.getBin utillinux}/sbin/mkswap \
--replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \
--replace /sbin/swapoff ${lib.getBin utillinux}/sbin/swapoff \
--replace /sbin/mke2fs ${lib.getBin e2fsprogs}/sbin/mke2fs \
--replace /sbin/fsck ${lib.getBin utillinux}/sbin/fsck \
--replace /bin/echo ${coreutils}/bin/echo \
--replace /bin/cat ${coreutils}/bin/cat \
--replace /sbin/sulogin ${lib.getBin utillinux}/sbin/sulogin \
Expand Down Expand Up @@ -272,14 +357,17 @@ in stdenv.mkDerivation {
NIX_CFLAGS_COMPILE = toString [
# Can't say ${polkit.bin}/bin/pkttyagent here because that would
# lead to a cyclic dependency.
"-UPOLKIT_AGENT_BINARY_PATH" "-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\""
"-UPOLKIT_AGENT_BINARY_PATH"
"-DPOLKIT_AGENT_BINARY_PATH=\"/run/current-system/sw/bin/pkttyagent\""

# 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.
"-USYSTEMD_CGROUP_AGENT_PATH" "-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\""
"-USYSTEMD_CGROUP_AGENT_PATH"
"-DSYSTEMD_CGROUP_AGENT_PATH=\"/run/current-system/systemd/lib/systemd/systemd-cgroups-agent\""

"-USYSTEMD_BINARY_PATH" "-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\""
"-USYSTEMD_BINARY_PATH"
"-DSYSTEMD_BINARY_PATH=\"/run/current-system/systemd/lib/systemd/systemd\""
];

doCheck = false; # fails a bunch of tests
Expand Down Expand Up @@ -311,7 +399,9 @@ in stdenv.mkDerivation {

# "kernel-install" shouldn't be used on NixOS.
find $out -name "*kernel-install*" -exec rm {} \;
''; # */
'' + lib.optionalString (!withDocumentation) ''
rm -rf $out/share/doc
'';

enableParallelBuilding = true;

Expand All @@ -323,7 +413,7 @@ in stdenv.mkDerivation {
# runtime; otherwise we can't and we need to reboot.
passthru.interfaceVersion = 2;

meta = with stdenv.lib; {
meta = with lib; {
homepage = "https://www.freedesktop.org/wiki/Software/systemd/";
description = "A system and service manager for Linux";
license = licenses.lgpl21Plus;
Expand Down
27 changes: 20 additions & 7 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18662,17 +18662,30 @@ in
};
systemdMinimal = systemd.override {
pname = "systemd-minimal";
withResolved = false;
withLogind = false;
withAnalyze = false;
withApparmor = false;
withCompression = false;
withCoredump = false;
withCryptsetup = false;
withDocumentation = false;
withEfi = false;
withHostnamed = false;
withLocaled = false;
withTimedated = false;
withHwdb = false;
withEfi = false;
withImportd = false;
withCryptsetup = false;
cryptsetup = null;
withLocaled = false;
withLogind = false;
withMachined = false;
withNetworkd = false;
withNss = false;
withPCRE2 = false;
withPolkit = false;
withResolved = false;
withShellCompletions = false;
withTimedated = false;
withTimesyncd = false;
withUserDb = false;
glib = null;
libgcrypt = null;
lvm2 = null;
};

Expand Down