From 0daf6f612a45b30007d06948ad930889f0e1ff98 Mon Sep 17 00:00:00 2001 From: ranomier Date: Sun, 24 Nov 2024 02:02:55 +0100 Subject: [PATCH] make it ask --- nswitch | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nswitch b/nswitch index a437a8d..4bfdec9 100755 --- a/nswitch +++ b/nswitch @@ -7,7 +7,15 @@ cd ~/Projects/NixOS/ nvim nix fmt . &>/dev/null 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 || ( cat nixos-switch.log | grep --color error && false) gen=$(nixos-rebuild list-generations | grep current)