nixos: test new auto-upgrade module
This commit is contained in:
parent
40e7f12b33
commit
a20dc996f5
|
@ -57,9 +57,9 @@ let cfg = config.system.autoUpgrade; in
|
|||
default = false;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Shall the system be rebooted if the new configuration
|
||||
uses a different kernel, kernel modules or initrd
|
||||
than the booted system?
|
||||
Reboot the system into the new generation instead of a switch
|
||||
if the new generation uses a different kernel, kernel modules
|
||||
or initrd than the booted system.
|
||||
'';
|
||||
};
|
||||
|
||||
|
@ -88,29 +88,25 @@ let cfg = config.system.autoUpgrade; in
|
|||
HOME = "/root";
|
||||
} // config.networking.proxy.envVars;
|
||||
|
||||
path = [ pkgs.gnutar pkgs.xz.bin pkgs.gitMinimal config.nix.package.out ];
|
||||
path = [ pkgs.coreutils pkgs.gnutar pkgs.xz.bin pkgs.gitMinimal config.nix.package.out ];
|
||||
|
||||
script = ''
|
||||
${lib.optionalString cfg.allowReboot ''
|
||||
set -euo pipefail
|
||||
T=$(mktemp -d)
|
||||
cd "$T"
|
||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild build ${toString cfg.flags}
|
||||
booted="$(${pkgs.coreutils}/bin/readlink /run/booted-system/{initrd,kernel,kernel-modules})"
|
||||
built="$(${pkgs.coreutils}/bin/readlink result/{initrd,kernel,kernel-modules})"
|
||||
cd /tmp
|
||||
rm -rf "$T"
|
||||
script = let
|
||||
nixos-rebuild = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild";
|
||||
in
|
||||
if cfg.allowReboot then ''
|
||||
${nixos-rebuild} boot ${toString cfg.flags}
|
||||
booted="$(readlink /run/booted-system/{initrd,kernel,kernel-modules})"
|
||||
built="$(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
||||
if [ "$booted" = "$built" ]; then
|
||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch ${toString cfg.flags}
|
||||
${nixos-rebuild} switch ${toString cfg.flags}
|
||||
else
|
||||
${config.system.build.nixos-rebuild}/bin/nixos-rebuild boot ${toString cfg.flags}
|
||||
/run/current-system/sw/bin/shutdown -r +1
|
||||
fi
|
||||
''}
|
||||
${lib.optionalString (!cfg.allowReboot) "${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch ${toString cfg.flags}"}
|
||||
'' else ''
|
||||
${nixos-rebuild} switch ${toString cfg.flags}
|
||||
'';
|
||||
|
||||
startAt = optional cfg.enable cfg.dates;
|
||||
startAt = cfg.dates;
|
||||
};
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue