2023-09-11 16:29:05 +00:00
|
|
|
# error handler
|
|
|
|
handle_error() {
|
|
|
|
echo "Upgrade failed."
|
|
|
|
read -p "Press Enter to exit..."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-09-03 11:12:45 +00:00
|
|
|
# stop on error
|
|
|
|
set -euxo pipefail
|
|
|
|
|
2023-09-11 16:29:05 +00:00
|
|
|
# trap any errors and call handle_error
|
|
|
|
trap 'handle_error "$BASH_COMMAND"' ERR
|
|
|
|
|
2023-09-03 11:12:45 +00:00
|
|
|
# update lock file
|
|
|
|
nix flake update
|
|
|
|
|
|
|
|
# update systems
|
|
|
|
sudo nixos-rebuild switch -L --flake .#neodymium
|
|
|
|
nixos-rebuild switch -L --flake .#hydrogen --target-host hydrogen
|
|
|
|
|
|
|
|
# commit and push lock file
|
|
|
|
git add flake.lock
|
|
|
|
git commit -m "⬆️ nix flake update"
|
|
|
|
git push
|
2023-09-11 16:29:05 +00:00
|
|
|
|
|
|
|
echo "Upgrade successful"
|