summary refs log tree commit diff
path: root/modules/system/boot/kexec.nix
blob: b7821f9509f12bba10dd3dfc92d2c683c5308026 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{ config, pkgs, ... }:

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

}