From d63da5892cf79df5d66cdc76430ccd371bd5fb71 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 11 Oct 2012 17:58:46 -0400 Subject: [PATCH] Ensure that systemd-modules-load is restarted when boot.kernelModules changes --- modules/system/boot/kernel.nix | 36 ++++++++++++++++++++++++++++----- modules/system/boot/systemd.nix | 2 +- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/modules/system/boot/kernel.nix b/modules/system/boot/kernel.nix index 8a660b90581b..130adb1110a1 100644 --- a/modules/system/boot/kernel.nix +++ b/modules/system/boot/kernel.nix @@ -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 = { diff --git a/modules/system/boot/systemd.nix b/modules/system/boot/systemd.nix index d88ac652ae0e..0ccb30eb92f2 100644 --- a/modules/system/boot/systemd.nix +++ b/modules/system/boot/systemd.nix @@ -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"