mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos: kexec: Disable on non-keexecable systems.
This commit is contained in:
parent
d61a22fb0e
commit
a929301281
1 changed files with 19 additions and 18 deletions
|
@ -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" =
|
systemd.services."prepare-kexec" =
|
||||||
{ description = "Preparation for kexec";
|
{ description = "Preparation for kexec";
|
||||||
wantedBy = [ "kexec.target" ];
|
wantedBy = [ "kexec.target" ];
|
||||||
before = [ "systemd-kexec.service" ];
|
before = [ "systemd-kexec.service" ];
|
||||||
unitConfig.DefaultDependencies = false;
|
unitConfig.DefaultDependencies = false;
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
path = [ pkgs.kexectools ];
|
path = [ pkgs.kexectools ];
|
||||||
script =
|
script =
|
||||||
''
|
''
|
||||||
p=$(readlink -f /nix/var/nix/profiles/system)
|
p=$(readlink -f /nix/var/nix/profiles/system)
|
||||||
if ! [ -d $p ]; then exit 1; fi
|
if ! [ -d $p ]; then exit 1; fi
|
||||||
exec kexec --load $p/kernel --initrd=$p/initrd --append="$(cat $p/kernel-params) init=$p/init"
|
exec kexec --load $p/kernel --initrd=$p/initrd --append="$(cat $p/kernel-params) init=$p/init"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue