Merge pull request #261798 from blitz/systemd-minimization

Avoid Two Sets of systemd Binaries in System Closure
This commit is contained in:
Florian Klink 2023-10-24 18:51:28 +03:00 committed by GitHub
commit 87896bfdd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 19 deletions

View file

@ -43,3 +43,12 @@ Disables using Mesons `checkPhase`.
### `dontUseMesonInstall` {#dontusemesoninstall}
Disables using Mesons `installPhase`.
### `mesonInstallFlags` {#mesoninstallflags}
Controls the flags passed to meson install.
### `mesonInstallTags` (#mesoninstalltags)
Tags specified here will be passed to Meson as via `--tags` during
installation and controls which components will be installed.

View file

@ -55,6 +55,10 @@ mesonInstallPhase() {
# shellcheck disable=SC2086
local flagsArray=($mesonInstallFlags "${mesonInstallFlagsArray[@]}")
if [[ -n "$mesonInstallTags" ]]; then
flagsArray+=("--tags" "${mesonInstallTags// /,}")
fi
echoCmd 'install flags' "${flagsArray[@]}"
meson install --no-rebuild "${flagsArray[@]}"

View file

@ -134,6 +134,8 @@
, withUtmp ? !stdenv.hostPlatform.isMusl
# tests assume too much system access for them to be feasible for us right now
, withTests ? false
# build only libudev and libsystemd
, buildLibsOnly ? false
# name argument
, pname ? "systemd"
@ -380,7 +382,7 @@ stdenv.mkDerivation (finalAttrs: {
patchShebangs tools test src/!(rpm|kernel-install|ukify) src/kernel-install/test-kernel-install.sh
'';
outputs = [ "out" "man" "dev" ];
outputs = [ "out" "dev" ] ++ (lib.optional (!buildLibsOnly) "man");
nativeBuildInputs =
[
@ -444,7 +446,7 @@ stdenv.mkDerivation (finalAttrs: {
++ lib.optional withUkify (python3Packages.python.withPackages (ps: with ps; [ pefile ]))
;
#dontAddPrefix = true;
mesonBuildType = "release";
mesonFlags = [
"-Dversion-tag=${version}"
@ -705,7 +707,9 @@ stdenv.mkDerivation (finalAttrs: {
export DESTDIR=/
'';
postInstall = ''
mesonInstallTags = lib.optionals buildLibsOnly [ "devel" "libudev" "libsystemd" ];
postInstall = lib.optionalString (!buildLibsOnly) ''
mkdir -p $out/example/systemd
mv $out/lib/{binfmt.d,sysctl.d,tmpfiles.d} $out/example
mv $out/lib/systemd/{system,user} $out/example/systemd
@ -723,7 +727,7 @@ stdenv.mkDerivation (finalAttrs: {
find $out -name "*kernel-install*" -exec rm {} \;
'' + lib.optionalString (!withDocumentation) ''
rm -rf $out/share/doc
'' + lib.optionalString withKmod ''
'' + lib.optionalString (withKmod && !buildLibsOnly) ''
mv $out/lib/modules-load.d $out/example
'';

View file

@ -8,7 +8,7 @@
, python3
, dbus
, polkit
, systemdMinimal
, systemdLibs
, IOKit
, pname ? "pcsclite"
, polkitSupport ? false
@ -59,7 +59,7 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ autoreconfHook autoconf-archive pkg-config perl ];
buildInputs = [ python3 ]
++ lib.optionals stdenv.isLinux [ systemdMinimal ]
++ lib.optionals stdenv.isLinux [ systemdLibs ]
++ lib.optionals stdenv.isDarwin [ IOKit ]
++ lib.optionals polkitSupport [ dbus polkit ];

View file

@ -22036,8 +22036,6 @@ with pkgs;
hidapi = callPackage ../development/libraries/hidapi {
inherit (darwin.apple_sdk.frameworks) Cocoa IOKit;
# TODO: remove once `udev` is `systemdMinimal` everywhere.
udev = systemdMinimal;
};
highfive = callPackage ../development/libraries/highfive { };
@ -22741,9 +22739,7 @@ with pkgs;
libfakekey = callPackage ../development/libraries/libfakekey { };
libfido2 = callPackage ../development/libraries/libfido2 {
udev = systemdMinimal;
};
libfido2 = callPackage ../development/libraries/libfido2 {};
libfilezilla = darwin.apple_sdk_11_0.callPackage ../development/libraries/libfilezilla {
inherit (darwin.apple_sdk_11_0.frameworks) ApplicationServices;
@ -23619,8 +23615,6 @@ with pkgs;
libusb1 = callPackage ../development/libraries/libusb1 {
inherit (darwin) libobjc;
inherit (darwin.apple_sdk.frameworks) IOKit Security;
# TODO: remove once `udev` is `systemdMinimal` everywhere.
udev = systemdMinimal;
};
libusbgx = callPackage ../development/libraries/libusbgx { };
@ -28265,10 +28259,6 @@ with pkgs;
lsscsi = callPackage ../os-specific/linux/lsscsi { };
lvm2 = callPackage ../os-specific/linux/lvm2/2_03.nix {
# udev is the same package as systemd which depends on cryptsetup
# which depends on lvm2 again. But we only need the libudev part
# which does not depend on cryptsetup.
udev = systemdMinimal;
# break the cyclic dependency:
# util-linux (non-minimal) depends (optionally, but on by default) on systemd,
# systemd (optionally, but on by default) on cryptsetup and cryptsetup depends on lvm2
@ -28805,11 +28795,14 @@ with pkgs;
withUkify = false;
withBootloader = false;
};
systemdLibs = systemdMinimal.override {
pname = "systemd-minimal-libs";
buildLibsOnly = true;
};
udev =
if (with stdenv.hostPlatform; isLinux && isStatic) then libudev-zero
else systemd; # TODO: change to systemdMinimal
else systemdLibs;
systemd-wait = callPackage ../os-specific/linux/systemd-wait { };