make it ask

This commit is contained in:
Ranomier 2024-11-24 02:02:55 +01:00
parent b39b82463b
commit 0daf6f612a

10
nswitch
View file

@ -7,7 +7,15 @@ cd ~/Projects/NixOS/
nvim nvim
nix fmt . &>/dev/null nix fmt . &>/dev/null
git diff -U0 *.nix git diff -U0 *.nix
echo "NixOS Rebuilding..."
echo "Do you want to rebuild NixOS? [y/N]"
read -r YESNO
if ! [[ "${YESNO,,}" == "y" ]]; then
echo "Exiting ..."
exit 1
fi
echo "Rebuilding NixOS"
sudo nixos-rebuild switch &>nixos-switch.log || ( sudo nixos-rebuild switch &>nixos-switch.log || (
cat nixos-switch.log | grep --color error && false) cat nixos-switch.log | grep --color error && false)
gen=$(nixos-rebuild list-generations | grep current) gen=$(nixos-rebuild list-generations | grep current)