nixos: kexec: Disable on non-keexecable systems.

This commit is contained in:
Shea Levy 2018-02-27 20:34:13 -05:00
parent d61a22fb0e
commit a929301281
No known key found for this signature in database
GPG key ID: 5C0BD6957D86FE27

View file

@ -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"
'';
};
}
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"
'';
};
};
}