diff options
author | Shea Levy <shea@shealevy.com> | 2018-02-27 20:34:13 -0500 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2018-02-28 15:01:31 -0500 |
commit | a92930128145113d3a7d1eb91c449dc7bb7cc455 (patch) | |
tree | f957c23328a387fced0b0ee500c6e1dad1cd8711 /nixos | |
parent | d61a22fb0e5f48f7559e1ff91dad228a37d6cb9e (diff) |
nixos: kexec: Disable on non-keexecable systems.
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/system/boot/kexec.nix | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/nixos/modules/system/boot/kexec.nix b/nixos/modules/system/boot/kexec.nix index b7821f9509f12..14ebe66e63204 100644 --- a/nixos/modules/system/boot/kexec.nix +++ b/nixos/modules/system/boot/kexec.nix @@ -1,21 +1,22 @@ -{ config, pkgs, ... }: +{ config, pkgs, lib, ... }: { - environment.systemPackages = [ pkgs.kexectools ]; + config = lib.mkIf (pkgs.kexectools != null) { + environment.systemPackages = [ pkgs.kexectools ]; - systemd.services."prepare-kexec" = - { description = "Preparation for kexec"; - wantedBy = [ "kexec.target" ]; - before = [ "systemd-kexec.service" ]; - unitConfig.DefaultDependencies = false; - serviceConfig.Type = "oneshot"; - path = [ pkgs.kexectools ]; - script = - '' - p=$(readlink -f /nix/var/nix/profiles/system) - if ! [ -d $p ]; then exit 1; fi - exec kexec --load $p/kernel --initrd=$p/initrd --append="$(cat $p/kernel-params) init=$p/init" - ''; - }; - -} \ No newline at end of file + systemd.services."prepare-kexec" = + { description = "Preparation for kexec"; + wantedBy = [ "kexec.target" ]; + before = [ "systemd-kexec.service" ]; + unitConfig.DefaultDependencies = false; + serviceConfig.Type = "oneshot"; + path = [ pkgs.kexectools ]; + script = + '' + p=$(readlink -f /nix/var/nix/profiles/system) + if ! [ -d $p ]; then exit 1; fi + exec kexec --load $p/kernel --initrd=$p/initrd --append="$(cat $p/kernel-params) init=$p/init" + ''; + }; + }; +} |