Merge pull request #101886 from flokli/systemd-more-optional
systemd: introduce more options for a more minimal build
This commit is contained in:
commit
d64f4d03d5
@ -1,60 +1,110 @@
|
|||||||
{ stdenv, lib, fetchFromGitHub
|
{ stdenv
|
||||||
|
, lib
|
||||||
|
, fetchFromGitHub
|
||||||
, buildPackages
|
, buildPackages
|
||||||
, ninja, meson, m4, pkgconfig, coreutils, gperf, getent
|
, ninja
|
||||||
, patchelf, perl, glibcLocales, glib, substituteAll
|
, meson
|
||||||
, gettext, python3Packages
|
, m4
|
||||||
|
, pkgconfig
|
||||||
|
, coreutils
|
||||||
|
, gperf
|
||||||
|
, getent
|
||||||
|
, patchelf
|
||||||
|
, glibcLocales
|
||||||
|
, glib
|
||||||
|
, substituteAll
|
||||||
|
, gettext
|
||||||
|
, python3Packages
|
||||||
|
|
||||||
# Mandatory dependencies
|
# Mandatory dependencies
|
||||||
, libcap
|
, libcap
|
||||||
, utillinux
|
, utillinux
|
||||||
, kbd
|
, kbd
|
||||||
, kmod
|
, kmod
|
||||||
|
|
||||||
# Optional dependencies
|
# Optional dependencies
|
||||||
, pam, cryptsetup, lvm2, audit, acl
|
, pam
|
||||||
, lz4, libgcrypt, libgpgerror, libidn2
|
, cryptsetup
|
||||||
, curl, gnutar, gnupg, zlib
|
, lvm2
|
||||||
, xz, libuuid, libffi
|
, audit
|
||||||
, libapparmor, intltool
|
, acl
|
||||||
, bzip2, pcre2, e2fsprogs
|
, lz4
|
||||||
|
, libgcrypt
|
||||||
|
, libgpgerror
|
||||||
|
, libidn2
|
||||||
|
, curl
|
||||||
|
, gnutar
|
||||||
|
, gnupg
|
||||||
|
, zlib
|
||||||
|
, xz
|
||||||
|
, libuuid
|
||||||
|
, libapparmor
|
||||||
|
, intltool
|
||||||
|
, bzip2
|
||||||
|
, pcre2
|
||||||
|
, e2fsprogs
|
||||||
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
|
, linuxHeaders ? stdenv.cc.libc.linuxHeaders
|
||||||
, gnu-efi
|
, gnu-efi
|
||||||
, iptables
|
, iptables
|
||||||
, withSelinux ? false, libselinux
|
, withSelinux ? false
|
||||||
, withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
|
, libselinux
|
||||||
, withKexectools ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) kexectools.meta.platforms, kexectools
|
, 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
|
, bashInteractive
|
||||||
|
|
||||||
, withResolved ? true
|
, withAnalyze ? true
|
||||||
, withLogind ? true
|
, withApparmor ? true
|
||||||
|
, withCoredump ? true
|
||||||
|
, withCompression ? true # adds bzip2, lz4 and xz
|
||||||
|
, withCryptsetup ? true
|
||||||
|
, withDocumentation ? true
|
||||||
|
, withEfi ? stdenv.hostPlatform.isEfi
|
||||||
, withHostnamed ? true
|
, withHostnamed ? true
|
||||||
|
, withHwdb ? true
|
||||||
|
, withImportd ? true
|
||||||
, withLocaled ? true
|
, withLocaled ? true
|
||||||
|
, withLogind ? true
|
||||||
|
, withMachined ? true
|
||||||
, withNetworkd ? true
|
, withNetworkd ? true
|
||||||
|
, withNss ? true
|
||||||
|
, withPCRE2 ? true
|
||||||
|
, withPolkit ? true
|
||||||
|
, withRemote ? false # has always been disabled on NixOS, upstream version appears broken anyway
|
||||||
|
, withResolved ? true
|
||||||
|
, withShellCompletions ? true
|
||||||
, withTimedated ? true
|
, withTimedated ? true
|
||||||
, withTimesyncd ? true
|
, withTimesyncd ? true
|
||||||
, withHwdb ? true
|
, withUserDb ? true
|
||||||
, withEfi ? stdenv.hostPlatform.isEfi
|
|
||||||
, withImportd ? true
|
|
||||||
, withCryptsetup ? true
|
|
||||||
|
|
||||||
# name argument
|
# name argument
|
||||||
, pname ? "systemd"
|
, 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 withResolved -> (libgcrypt != null && libgpgerror != null);
|
||||||
assert withImportd ->
|
assert withImportd ->
|
||||||
( curl.dev != null && zlib != null && xz != null && libgcrypt != null
|
(curl.dev != null && zlib != null && xz != null && libgcrypt != null
|
||||||
&& gnutar != null && gnupg != null);
|
&& gnutar != null && gnupg != null && withCompression );
|
||||||
|
|
||||||
|
assert withEfi -> (gnu-efi != null);
|
||||||
|
assert withRemote -> lib.getDev curl != null;
|
||||||
|
assert withCoredump -> withCompression;
|
||||||
|
|
||||||
assert withCryptsetup ->
|
assert withCryptsetup ->
|
||||||
( cryptsetup != null );
|
(cryptsetup != null);
|
||||||
|
|
||||||
let
|
let
|
||||||
|
wantCurl = withRemote || withImportd;
|
||||||
|
|
||||||
version = "246.6";
|
version = "246.6";
|
||||||
in stdenv.mkDerivation {
|
in
|
||||||
|
stdenv.mkDerivation {
|
||||||
inherit version pname;
|
inherit version pname;
|
||||||
|
|
||||||
# We use systemd/systemd-stable for src, and ship NixOS-specific patches inside nixpkgs directly
|
# We use systemd/systemd-stable for src, and ship NixOS-specific patches inside nixpkgs directly
|
||||||
@ -105,29 +155,53 @@ in stdenv.mkDerivation {
|
|||||||
outputs = [ "out" "man" "dev" ];
|
outputs = [ "out" "man" "dev" ];
|
||||||
|
|
||||||
nativeBuildInputs =
|
nativeBuildInputs =
|
||||||
[ pkgconfig gperf
|
[
|
||||||
ninja meson
|
pkgconfig
|
||||||
|
gperf
|
||||||
|
ninja
|
||||||
|
meson
|
||||||
coreutils # meson calls date, stat etc.
|
coreutils # meson calls date, stat etc.
|
||||||
glibcLocales
|
glibcLocales
|
||||||
patchelf getent m4
|
patchelf
|
||||||
perl # to patch the libsystemd.so and remove dependencies on aarch64
|
getent
|
||||||
|
m4
|
||||||
|
|
||||||
intltool
|
intltool
|
||||||
gettext
|
gettext
|
||||||
|
|
||||||
libxslt docbook_xsl docbook_xml_dtd_42 docbook_xml_dtd_45
|
libxslt
|
||||||
(buildPackages.python3Packages.python.withPackages ( ps: with ps; [ python3Packages.lxml ]))
|
docbook_xsl
|
||||||
|
docbook_xml_dtd_42
|
||||||
|
docbook_xml_dtd_45
|
||||||
|
(buildPackages.python3Packages.python.withPackages (ps: with ps; [ python3Packages.lxml ]))
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs =
|
buildInputs =
|
||||||
[ linuxHeaders libcap curl.dev kmod xz pam acl
|
[
|
||||||
cryptsetup libuuid glib libgcrypt libgpgerror libidn2
|
acl
|
||||||
pcre2 ] ++
|
audit
|
||||||
stdenv.lib.optional withKexectools kexectools ++
|
glib
|
||||||
stdenv.lib.optional withLibseccomp libseccomp ++
|
kmod
|
||||||
[ libffi audit lz4 bzip2 libapparmor iptables ] ++
|
libcap
|
||||||
stdenv.lib.optional withEfi gnu-efi ++
|
libgcrypt
|
||||||
stdenv.lib.optional withSelinux libselinux ++
|
libidn2
|
||||||
stdenv.lib.optional withCryptsetup cryptsetup.dev;
|
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;
|
#dontAddPrefix = true;
|
||||||
|
|
||||||
@ -143,28 +217,33 @@ in stdenv.mkDerivation {
|
|||||||
"-Dsetfont-path=${kbd}/bin/setfont"
|
"-Dsetfont-path=${kbd}/bin/setfont"
|
||||||
"-Dtty-gid=3" # tty in NixOS has gid 3
|
"-Dtty-gid=3" # tty in NixOS has gid 3
|
||||||
"-Ddebug-shell=${bashInteractive}/bin/bash"
|
"-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
|
# while we do not run tests we should also not build them. Removes about 600 targets
|
||||||
"-Dtests=false"
|
"-Dtests=false"
|
||||||
"-Dimportd=${stdenv.lib.boolToString withImportd}"
|
"-Danalyze=${lib.boolToString withAnalyze}"
|
||||||
"-Dlz4=true"
|
"-Dgcrypt=${lib.boolToString (libgcrypt != null)}"
|
||||||
|
"-Dimportd=${lib.boolToString withImportd}"
|
||||||
|
"-Dlz4=${lib.boolToString withCompression}"
|
||||||
"-Dhomed=false"
|
"-Dhomed=false"
|
||||||
"-Dlogind=${stdenv.lib.boolToString withLogind}"
|
"-Dlogind=${lib.boolToString withLogind}"
|
||||||
"-Dlocaled=${stdenv.lib.boolToString withLocaled}"
|
"-Dlocaled=${lib.boolToString withLocaled}"
|
||||||
"-Dhostnamed=${stdenv.lib.boolToString withHostnamed}"
|
"-Dhostnamed=${lib.boolToString withHostnamed}"
|
||||||
"-Dnetworkd=${stdenv.lib.boolToString withNetworkd}"
|
"-Dmachined=${lib.boolToString withMachined}"
|
||||||
"-Dcryptsetup=${stdenv.lib.boolToString withCryptsetup}"
|
"-Dnetworkd=${lib.boolToString withNetworkd}"
|
||||||
|
"-Dpolkit=${lib.boolToString withPolkit}"
|
||||||
|
"-Dcryptsetup=${lib.boolToString withCryptsetup}"
|
||||||
"-Dportabled=false"
|
"-Dportabled=false"
|
||||||
"-Dhwdb=${stdenv.lib.boolToString withHwdb}"
|
"-Dhwdb=${lib.boolToString withHwdb}"
|
||||||
"-Dremote=false"
|
"-Dremote=${lib.boolToString withRemote}"
|
||||||
"-Dsysusers=false"
|
"-Dsysusers=false"
|
||||||
"-Dtimedated=${stdenv.lib.boolToString withTimedated}"
|
"-Dtimedated=${lib.boolToString withTimedated}"
|
||||||
"-Dtimesyncd=${stdenv.lib.boolToString withTimesyncd}"
|
"-Dtimesyncd=${lib.boolToString withTimesyncd}"
|
||||||
|
"-Duserdb=${lib.boolToString withUserDb}"
|
||||||
|
"-Dcoredump=${lib.boolToString withCoredump}"
|
||||||
"-Dfirstboot=false"
|
"-Dfirstboot=false"
|
||||||
"-Dlocaled=true"
|
"-Dresolve=${lib.boolToString withResolved}"
|
||||||
"-Dresolve=${stdenv.lib.boolToString withResolved}"
|
|
||||||
"-Dsplit-usr=false"
|
"-Dsplit-usr=false"
|
||||||
"-Dlibcurl=true"
|
"-Dlibcurl=${lib.boolToString wantCurl}"
|
||||||
"-Dlibidn=false"
|
"-Dlibidn=false"
|
||||||
"-Dlibidn2=true"
|
"-Dlibidn2=true"
|
||||||
"-Dquotacheck=false"
|
"-Dquotacheck=false"
|
||||||
@ -201,11 +280,20 @@ in stdenv.mkDerivation {
|
|||||||
# more frequent development builds
|
# more frequent development builds
|
||||||
"-Dman=true"
|
"-Dman=true"
|
||||||
|
|
||||||
"-Dgnu-efi=${stdenv.lib.boolToString (withEfi && gnu-efi != null)}"
|
"-Defi=${lib.boolToString withEfi}"
|
||||||
] ++ stdenv.lib.optionals (withEfi && gnu-efi != null) [
|
"-Dgnu-efi=${lib.boolToString withEfi}"
|
||||||
|
] ++ lib.optionals withEfi [
|
||||||
"-Defi-libdir=${toString gnu-efi}/lib"
|
"-Defi-libdir=${toString gnu-efi}/lib"
|
||||||
"-Defi-includedir=${toString gnu-efi}/include/efi"
|
"-Defi-includedir=${toString gnu-efi}/include/efi"
|
||||||
"-Defi-ldsdir=${toString gnu-efi}/lib"
|
"-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 = ''
|
preConfigure = ''
|
||||||
@ -217,7 +305,6 @@ in stdenv.mkDerivation {
|
|||||||
src/core/mount.c \
|
src/core/mount.c \
|
||||||
src/core/swap.c \
|
src/core/swap.c \
|
||||||
src/cryptsetup/cryptsetup-generator.c \
|
src/cryptsetup/cryptsetup-generator.c \
|
||||||
src/fsck/fsck.c \
|
|
||||||
src/journal/cat.c \
|
src/journal/cat.c \
|
||||||
src/nspawn/nspawn.c \
|
src/nspawn/nspawn.c \
|
||||||
src/remount-fs/remount-fs.c \
|
src/remount-fs/remount-fs.c \
|
||||||
@ -234,8 +321,6 @@ in stdenv.mkDerivation {
|
|||||||
--replace /sbin/mkswap ${lib.getBin utillinux}/sbin/mkswap \
|
--replace /sbin/mkswap ${lib.getBin utillinux}/sbin/mkswap \
|
||||||
--replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \
|
--replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \
|
||||||
--replace /sbin/swapoff ${lib.getBin utillinux}/sbin/swapoff \
|
--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/echo ${coreutils}/bin/echo \
|
||||||
--replace /bin/cat ${coreutils}/bin/cat \
|
--replace /bin/cat ${coreutils}/bin/cat \
|
||||||
--replace /sbin/sulogin ${lib.getBin utillinux}/sbin/sulogin \
|
--replace /sbin/sulogin ${lib.getBin utillinux}/sbin/sulogin \
|
||||||
@ -272,14 +357,17 @@ in stdenv.mkDerivation {
|
|||||||
NIX_CFLAGS_COMPILE = toString [
|
NIX_CFLAGS_COMPILE = toString [
|
||||||
# Can't say ${polkit.bin}/bin/pkttyagent here because that would
|
# Can't say ${polkit.bin}/bin/pkttyagent here because that would
|
||||||
# lead to a cyclic dependency.
|
# 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
|
# Set the release_agent on /sys/fs/cgroup/systemd to the
|
||||||
# currently running systemd (/run/current-system/systemd) so
|
# currently running systemd (/run/current-system/systemd) so
|
||||||
# that we don't use an obsolete/garbage-collected release agent.
|
# 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
|
doCheck = false; # fails a bunch of tests
|
||||||
@ -311,7 +399,9 @@ in stdenv.mkDerivation {
|
|||||||
|
|
||||||
# "kernel-install" shouldn't be used on NixOS.
|
# "kernel-install" shouldn't be used on NixOS.
|
||||||
find $out -name "*kernel-install*" -exec rm {} \;
|
find $out -name "*kernel-install*" -exec rm {} \;
|
||||||
''; # */
|
'' + lib.optionalString (!withDocumentation) ''
|
||||||
|
rm -rf $out/share/doc
|
||||||
|
'';
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
@ -323,7 +413,7 @@ in stdenv.mkDerivation {
|
|||||||
# runtime; otherwise we can't and we need to reboot.
|
# runtime; otherwise we can't and we need to reboot.
|
||||||
passthru.interfaceVersion = 2;
|
passthru.interfaceVersion = 2;
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with lib; {
|
||||||
homepage = "https://www.freedesktop.org/wiki/Software/systemd/";
|
homepage = "https://www.freedesktop.org/wiki/Software/systemd/";
|
||||||
description = "A system and service manager for Linux";
|
description = "A system and service manager for Linux";
|
||||||
license = licenses.lgpl21Plus;
|
license = licenses.lgpl21Plus;
|
||||||
|
@ -18795,17 +18795,30 @@ in
|
|||||||
};
|
};
|
||||||
systemdMinimal = systemd.override {
|
systemdMinimal = systemd.override {
|
||||||
pname = "systemd-minimal";
|
pname = "systemd-minimal";
|
||||||
withResolved = false;
|
withAnalyze = false;
|
||||||
withLogind = false;
|
withApparmor = false;
|
||||||
withHostnamed = false;
|
withCompression = false;
|
||||||
withLocaled = false;
|
withCoredump = false;
|
||||||
withTimedated = false;
|
|
||||||
withHwdb = false;
|
|
||||||
withEfi = false;
|
|
||||||
withImportd = false;
|
|
||||||
withCryptsetup = false;
|
withCryptsetup = false;
|
||||||
cryptsetup = null;
|
withDocumentation = false;
|
||||||
|
withEfi = false;
|
||||||
|
withHostnamed = false;
|
||||||
|
withHwdb = false;
|
||||||
|
withImportd = false;
|
||||||
|
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;
|
glib = null;
|
||||||
|
libgcrypt = null;
|
||||||
lvm2 = null;
|
lvm2 = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user