Ensure that systemd-modules-load is restarted when boot.kernelModules changes

This commit is contained in:
Eelco Dolstra 2012-10-11 17:58:46 -04:00
parent 71a541afb6
commit d63da5892c
2 changed files with 32 additions and 6 deletions

View File

@ -2,7 +2,16 @@
with pkgs.lib;
let kernel = config.boot.kernelPackages.kernel; in
let
kernel = config.boot.kernelPackages.kernel;
kernelModulesConf = pkgs.writeText "nixos.conf"
''
${concatStringsSep "\n" config.boot.kernelModules}
'';
in
{
@ -197,10 +206,27 @@ let kernel = config.boot.kernelPackages.kernel; in
# this file changes.
environment.etc = singleton
{ target = "modules-load.d/nixos.conf";
source = pkgs.writeText "nixos.conf"
''
${concatStringsSep "\n" config.boot.kernelModules}
'';
source = kernelModulesConf;
};
# Sigh. This overrides systemd's systemd-modules-load.service
# just so we can set a restart trigger. Also make
# multi-user.target pull it in so that it gets started if it
# failed earlier.
boot.systemd.services."systemd-modules-load" =
{ description = "Load Kernel Modules";
wantedBy = [ "sysinit.target" "multi-user.target" ];
before = [ "sysinit.target" "shutdown.target" ];
unitConfig =
{ DefaultDependencies = "no";
Conflicts = "shutdown.target";
};
serviceConfig =
{ Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${config.system.build.systemd}/lib/systemd/systemd-modules-load";
};
restartTriggers = [ kernelModulesConf ];
};
lib.kernelConfig = {

View File

@ -76,7 +76,7 @@ let
"systemd-update-utmp-shutdown.service"
# Kernel module loading.
"systemd-modules-load.service"
#"systemd-modules-load.service"
# Filesystems.
"systemd-fsck@.service"