You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
924 B
Nix
26 lines
924 B
Nix
1 year ago
|
{ pkgs, ... }: {
|
||
|
system.autoUpgrade.enable = true;
|
||
|
system.autoUpgrade.flake = "git:git.newtype.fr/newtype/newtype-org-configurations";
|
||
|
system.autoUpgrade.flags = [ "--option" "accept-flake-config" "true" ];
|
||
|
|
||
|
# add a random jitter so not all machines reboot at the same time.
|
||
|
systemd.timers.auto-reboot.timerConfig.RandomizedDelaySec = 60 * 20;
|
||
|
|
||
|
systemd.services.auto-reboot = {
|
||
|
path = [ pkgs.systemd pkgs.util-linux ];
|
||
|
# The last saturday in a month
|
||
|
startAt = "Sat *-*~07/1";
|
||
|
script = ''
|
||
|
booted="$(readlink /run/booted-system/{initrd,kernel,kernel-modules})"
|
||
|
built="$(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
||
|
if [ "''${booted}" = "''${built}" ]; then
|
||
|
echo "No kernel update... skipping reboot"
|
||
|
else
|
||
|
# reboot in 24 hours
|
||
|
msg=$(shutdown -r +${toString (60 * 24)} 2>&1)
|
||
|
echo "$msg" | wall
|
||
|
fi
|
||
|
'';
|
||
|
};
|
||
|
}
|