2018-02-28 02:34:13 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2013-09-16 17:15:42 +02:00
|
|
|
|
|
|
|
{
|
2018-03-25 23:45:22 +02:00
|
|
|
config = lib.mkIf (pkgs.kexectools.meta.available) {
|
2018-02-28 02:34:13 +01:00
|
|
|
environment.systemPackages = [ pkgs.kexectools ];
|
2013-09-16 17:15:42 +02:00
|
|
|
|
2018-02-28 02:34:13 +01:00
|
|
|
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"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|