modules/nixos: separate reboot from auto-upgrade
This commit is contained in:
parent
68a4acdadd
commit
92e3a37e12
3 changed files with 21 additions and 19 deletions
modules/nixos/common
|
@ -1,25 +1,6 @@
|
||||||
{ config, pkgs, ... }:
|
|
||||||
{
|
{
|
||||||
system.autoUpgrade.enable = true;
|
system.autoUpgrade.enable = true;
|
||||||
system.autoUpgrade.flake = "github:nix-community/infra";
|
system.autoUpgrade.flake = "github:nix-community/infra";
|
||||||
system.autoUpgrade.dates = "hourly";
|
system.autoUpgrade.dates = "hourly";
|
||||||
system.autoUpgrade.flags = [ "--option" "accept-flake-config" "true" "--option" "tarball-ttl" "0" ];
|
system.autoUpgrade.flags = [ "--option" "accept-flake-config" "true" "--option" "tarball-ttl" "0" ];
|
||||||
|
|
||||||
# adapted from https://github.com/NixOS/nixpkgs/blob/3428bdf3c93a7608615dddd44dec50c3df89b4be/nixos/modules/tasks/auto-upgrade.nix
|
|
||||||
systemd.services.reboot-after-update = {
|
|
||||||
restartIfChanged = false;
|
|
||||||
unitConfig.X-StopOnRemoval = false;
|
|
||||||
serviceConfig.Type = "oneshot";
|
|
||||||
script = ''
|
|
||||||
booted="$(${pkgs.coreutils}/bin/readlink /run/booted-system/{initrd,kernel,kernel-modules})"
|
|
||||||
built="$(${pkgs.coreutils}/bin/readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
|
||||||
if [ "''${booted}" != "''${built}" ]; then
|
|
||||||
${config.systemd.package}/bin/shutdown -r now
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
startAt = "0/6:00";
|
|
||||||
};
|
|
||||||
systemd.timers.reboot-after-update = {
|
|
||||||
timerConfig.RandomizedDelaySec = "6h";
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
imports = [
|
imports = [
|
||||||
./auto-upgrade.nix
|
./auto-upgrade.nix
|
||||||
./nix-daemon.nix
|
./nix-daemon.nix
|
||||||
|
./reboot.nix
|
||||||
./security.nix
|
./security.nix
|
||||||
./sops-nix.nix
|
./sops-nix.nix
|
||||||
./users.nix
|
./users.nix
|
||||||
|
|
20
modules/nixos/common/reboot.nix
Normal file
20
modules/nixos/common/reboot.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{
|
||||||
|
# adapted from https://github.com/NixOS/nixpkgs/blob/3428bdf3c93a7608615dddd44dec50c3df89b4be/nixos/modules/tasks/auto-upgrade.nix
|
||||||
|
systemd.services.reboot-after-update = {
|
||||||
|
restartIfChanged = false;
|
||||||
|
unitConfig.X-StopOnRemoval = false;
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
booted="$(${pkgs.coreutils}/bin/readlink /run/booted-system/{initrd,kernel,kernel-modules})"
|
||||||
|
built="$(${pkgs.coreutils}/bin/readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
||||||
|
if [ "''${booted}" != "''${built}" ]; then
|
||||||
|
${config.systemd.package}/bin/shutdown -r now
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
startAt = "0/6:00";
|
||||||
|
};
|
||||||
|
systemd.timers.reboot-after-update = {
|
||||||
|
timerConfig.RandomizedDelaySec = "6h";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue