diff options
author | Garry Filakhtov <filakhtov@gmail.com> | 2023-02-21 18:48:27 +1100 |
---|---|---|
committer | Garry Filakhtov <filakhtov@gmail.com> | 2023-03-08 18:00:51 +1100 |
commit | 3be2b599651b3d7ed39ec52df25915a9b7a39218 (patch) | |
tree | 28148b8e0cf4a7f46cd61cee4ea78d7c7d250644 /pkgs/os-specific/linux/systemd/default.nix | |
parent | 2d17a968053a968667457f06971577fe002385c0 (diff) | |
download | nixpkgs-3be2b599651b3d7ed39ec52df25915a9b7a39218.tar nixpkgs-3be2b599651b3d7ed39ec52df25915a9b7a39218.tar.gz nixpkgs-3be2b599651b3d7ed39ec52df25915a9b7a39218.tar.bz2 nixpkgs-3be2b599651b3d7ed39ec52df25915a9b7a39218.tar.lz nixpkgs-3be2b599651b3d7ed39ec52df25915a9b7a39218.tar.xz nixpkgs-3be2b599651b3d7ed39ec52df25915a9b7a39218.tar.zst nixpkgs-3be2b599651b3d7ed39ec52df25915a9b7a39218.zip |
systemd: optional kmod integration
Expose a new `withKmod` option to be able to enable and disable kmod integration, including the `systemd-modules-load` tool for automatic modules loading during the system boot sequence.
Diffstat (limited to 'pkgs/os-specific/linux/systemd/default.nix')
-rw-r--r-- | pkgs/os-specific/linux/systemd/default.nix | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index 9b119c10f5f..073fd3af01f 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -96,6 +96,7 @@ , withHostnamed ? true , withHwdb ? true , withImportd ? !stdenv.hostPlatform.isMusl +, withKmod ? true , withLibBPF ? lib.versionAtLeast buildPackages.llvmPackages.clang.version "10.0" && stdenv.hostPlatform.isAarch -> lib.versionAtLeast stdenv.hostPlatform.parsed.cpu.version "6" # assumes hard floats && !stdenv.hostPlatform.isMips64 # see https://github.com/NixOS/nixpkgs/pull/194149#issuecomment-1266642211 @@ -381,7 +382,6 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ - kmod libxcrypt libcap libuuid @@ -400,6 +400,7 @@ stdenv.mkDerivation (finalAttrs: { ++ lib.optional withCryptsetup (lib.getDev cryptsetup.dev) ++ lib.optional withEfi gnu-efi ++ lib.optional withKexectools kexec-tools + ++ lib.optional withKmod kmod ++ lib.optional withLibidn2 libidn2 ++ lib.optional withLibseccomp libseccomp ++ lib.optional withNetworkd iptables @@ -496,7 +497,6 @@ stdenv.mkDerivation (finalAttrs: { "-Dsysvinit-path=" "-Dsysvrcnd-path=" - "-Dkmod-path=${kmod}/bin/kmod" "-Dsulogin-path=${util-linux}/bin/sulogin" "-Dmount-path=${util-linux}/bin/mount" "-Dumount-path=${util-linux}/bin/umount" @@ -530,6 +530,9 @@ stdenv.mkDerivation (finalAttrs: { ] ++ lib.optionals stdenv.hostPlatform.isMusl [ "-Dgshadow=false" "-Didn=false" + ] ++ lib.optionals withKmod [ + "-Dkmod=true" + "-Dkmod-path=${kmod}/bin/kmod" ]; preConfigure = let @@ -564,7 +567,6 @@ stdenv.mkDerivation (finalAttrs: { replacement = "${coreutils}/bin/cat"; where = [ "test/create-busybox-container" "test/test-execute/exec-noexecpaths-simple.service" "src/journal/cat.c" ]; } - { search = "/sbin/modprobe"; replacement = "${lib.getBin kmod}/sbin/modprobe"; where = [ "units/modprobe@.service" ]; } { search = "/usr/lib/systemd/systemd-fsck"; replacement = "$out/lib/systemd/systemd-fsck"; @@ -598,6 +600,8 @@ stdenv.mkDerivation (finalAttrs: { "src/import/pull-tar.c" ]; } + ] ++ lib.optionals withKmod [ + { search = "/sbin/modprobe"; replacement = "${lib.getBin kmod}/sbin/modprobe"; where = [ "units/modprobe@.service" ]; } ]; # { replacement, search, where } -> List[str] @@ -669,7 +673,7 @@ stdenv.mkDerivation (finalAttrs: { postInstall = '' mkdir -p $out/example/systemd - mv $out/lib/{modules-load.d,binfmt.d,sysctl.d,tmpfiles.d} $out/example + mv $out/lib/{binfmt.d,sysctl.d,tmpfiles.d} $out/example mv $out/lib/systemd/{system,user} $out/example/systemd rm -rf $out/etc/systemd/system @@ -685,6 +689,8 @@ stdenv.mkDerivation (finalAttrs: { find $out -name "*kernel-install*" -exec rm {} \; '' + lib.optionalString (!withDocumentation) '' rm -rf $out/share/doc + '' + lib.optionalString withKmod '' + mv $out/lib/modules-load.d $out/example ''; # Avoid *.EFI binary stripping. At least on aarch64-linux strip @@ -719,7 +725,7 @@ stdenv.mkDerivation (finalAttrs: { # runtime; otherwise we can't and we need to reboot. interfaceVersion = 2; - inherit withCryptsetup withHostnamed withImportd withLocaled withMachined withPortabled withTimedated withUtmp util-linux kmod kbd; + inherit withCryptsetup withHostnamed withImportd withKmod withLocaled withMachined withPortabled withTimedated withUtmp util-linux kmod kbd; tests = { inherit (nixosTests) switchTest; |