Add a script to safely update NixOS

This commit is contained in:
reo6 2024-09-06 17:52:52 +03:00
parent 1ad26d9ac3
commit 811d272187
3 changed files with 30 additions and 0 deletions

27
bin/nixos-update-script Executable file
View file

@ -0,0 +1,27 @@
#!/bin/sh
REPO_PATH="$HOME/dotfiles"
NIXOS_FOLDER="$REPO_PATH/nixos"
# Show git diff
cd $NIXOS_FOLDER
git diff
echo -e "\033[1mLast Commit Name:\033[0m $(git log -1 --pretty=format:'%s')"
# Ask user if they want to continue
if [[ $1 == "-sw" ]]; then
read -p "Do you want to continue? (y/n): " choice
if [[ $choice == "y" ]]; then
echo -e "\033[1m>>> sudo nixos-rebuild switch\033[0m"
sudo nixos-rebuild switch
else
echo "Operation cancelled."
fi
else
echo -e "\033[1m>>> sudo nixos-rebuild dry-run\033[0m"
sudo nixos-rebuild dry-run
fi