nixos/systemd/initrd: Check MODULES accurately (#512636)
This commit is contained in:
@@ -7,9 +7,29 @@
|
||||
...
|
||||
}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
filter
|
||||
elem
|
||||
filterAttrs
|
||||
concatLists
|
||||
mapAttrsToList
|
||||
getBin
|
||||
concatStringsSep
|
||||
mkEnableOption
|
||||
mkOption
|
||||
types
|
||||
literalExpression
|
||||
mkIf
|
||||
any
|
||||
isBool
|
||||
isString
|
||||
optionalAttrs
|
||||
mapAttrs'
|
||||
nameValuePair
|
||||
listToAttrs
|
||||
;
|
||||
|
||||
inherit (utils) systemdUtils escapeSystemdPath;
|
||||
inherit (systemdUtils.unitOptions) unitOption;
|
||||
inherit (systemdUtils.lib)
|
||||
@@ -27,6 +47,12 @@ let
|
||||
|
||||
cfg = config.boot.initrd.systemd;
|
||||
|
||||
withKmod =
|
||||
let
|
||||
kconfig = config.system.build.kernel.config;
|
||||
in
|
||||
kconfig.isSet "MODULES" -> kconfig.isYes "MODULES";
|
||||
|
||||
upstreamUnits = [
|
||||
"basic.target"
|
||||
"breakpoint-pre-udev.service"
|
||||
@@ -505,7 +531,7 @@ in
|
||||
pkgs.coreutils
|
||||
cfg.package
|
||||
]
|
||||
++ lib.optional (config.system.build.kernel.config.isYes "MODULES") cfg.package.kmod
|
||||
++ lib.optional withKmod cfg.package.kmod
|
||||
++ lib.optionals cfg.shell.enable [
|
||||
# bashInteractive is easier to use and also required by debug-shell.service
|
||||
pkgs.bashInteractive
|
||||
@@ -555,7 +581,7 @@ in
|
||||
// optionalAttrs (config.environment.etc ? "modprobe.d/nixos.conf") {
|
||||
"/etc/modprobe.d/nixos.conf".source = config.environment.etc."modprobe.d/nixos.conf".source;
|
||||
}
|
||||
// optionalAttrs (with config.system.build.kernel.config; isSet "MODULES" -> isYes "MODULES") {
|
||||
// optionalAttrs withKmod {
|
||||
"/lib".source = "${config.system.build.modulesClosure}/lib";
|
||||
|
||||
"/etc/modules-load.d/nixos.conf".text = concatStringsSep "\n" config.boot.initrd.kernelModules;
|
||||
@@ -640,7 +666,7 @@ in
|
||||
) cfg.automounts
|
||||
);
|
||||
|
||||
services."modprobe@" = lib.mkIf (config.system.build.kernel.config.isYes "MODULES") {
|
||||
services."modprobe@" = lib.mkIf withKmod {
|
||||
serviceConfig.ExecSearchPath = lib.makeBinPath [ cfg.package.kmod ];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user