Skip to content

Commit

Permalink
modules/nixos/common/update: cancel unnecessary reboots
Browse files Browse the repository at this point in the history
this is needed if the host is updated to a newer generation that doesn't require a reboot or is reverted to the current generation
  • Loading branch information
zowoq committed Jan 6, 2025
1 parent 55ea0ae commit 8528527
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nixos/common/update.bash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ arch=$(uname -m)
hostname=$(uname -n)
p=$(curl -L https://buildbot.nix-community.org/nix-outputs/nix-community/infra/master/"$arch"-linux.host-"$hostname")

cancel_reboot() {
if [[ -e /run/systemd/shutdown/scheduled ]]; then
shutdown -c
kexec --unload
fi
}

if [[ "$(readlink /run/current-system)" == "$p" ]]; then
cancel_reboot
exit 0
fi

Expand All @@ -26,5 +34,6 @@ if [[ $booted != "$built" ]]; then
shutdown -r "+$(shuf -i 5-60 -n 1)"
fi
else
cancel_reboot
/nix/var/nix/profiles/system/bin/switch-to-configuration switch
fi

0 comments on commit 8528527

Please sign in to comment.