This commit is contained in:
Marta 2025-06-08 03:15:30 +02:00
parent 8ab2eb9b93
commit f4d574f578

22
nixie
View file

@ -16,16 +16,16 @@ QUIT1 () {
} }
CHOOSE_CASE () { CHOOSE_CASE () {
echo -e -n "${IPurple}Build changes? ${Purple}Yes/Preview/Edit/Restore/Quit (y/p/e/r/q): ${NC}" echo -e -n "${IPurple}What do you want to do? ${Purple}Edit/reBuild/reView/Restore/Quit (e/b/v/r/q): ${NC}"
read CHOICE read CHOICE
case $CHOICE in case $CHOICE in
[yY]* ) BUILD ;;
[pP]* ) PREVIEW ;;
[eE]* ) EDIT ;; [eE]* ) EDIT ;;
[bB]* ) BUILD ;;
[vV]* ) REVIEW ;;
[rR]* ) RESTORE ;; [rR]* ) RESTORE ;;
[qQ]* ) echo -e "${IPurple}Quitting nixie. ${Purple}Changes kept in /etc/nixos.${NC}" && QUIT ;; [qQ]* ) echo -e "${IPurple}Quitting nixie. ${Purple}Changes kept in /etc/nixos.${NC}" && QUIT ;;
*) echo -e -n "[ ${Red}incorrect input ${NC}] " && CHOOSE_CASE ;; *) echo -e -n "[ ${Yellow}incorrect input ${NC}] " && CHOOSE_CASE ;;
esac esac
} }
@ -34,7 +34,7 @@ BUILD () {
echo -e -n "${IPurple}Are you sure you want to do this? ${Purple}Yes/No (Y/n): ${NC}" echo -e -n "${IPurple}Are you sure you want to do this? ${Purple}Yes/No (Y/n): ${NC}"
read CHOICE read CHOICE
case $CHOICE in case $CHOICE in
[nN]* ) echo -e -n "[ ${Red}cancelled ${NC}] " && CHOOSE_CASE ;; [nN]* ) echo -e -n "[ ${Yellow}cancelled ${NC}] " && CHOOSE_CASE ;;
*) *)
sudo git add . sudo git add .
echo -e "${IPurple}Rebuilding NixOS...${NC}" echo -e "${IPurple}Rebuilding NixOS...${NC}"
@ -67,7 +67,8 @@ BUILD () {
esac esac
} }
PREVIEW () { REVIEW () {
echo -e "${IPurple}Showing changes...${NC}"
sudo git diff sudo git diff
CHOOSE_CASE CHOOSE_CASE
} }
@ -80,16 +81,15 @@ EDIT () {
} }
RESTORE () { RESTORE () {
echo -e "[ ${Yellow}Warning ${NC}] ${Purple}This will restore /etc/nixos to the last commit.${NC}" echo -e "[ ${Yellow}warning ${NC}] ${Purple}This will restore /etc/nixos to the last commit.${NC}"
echo -e -n "[ ${Yellow}Warning ${NC}] ${Purple}Are you sure you want to disregard the changes? Yes/No (y/N): ${NC}" echo -e -n "[ ${Yellow}warning ${NC}] ${Purple}Are you sure you want to disregard the changes? Yes/No (y/N): ${NC}"
read CHOICE read CHOICE
case $CHOICE in case $CHOICE in
[yY]* ) sudo -k git restore . && echo -e "${IPurple}Quitting nixie. ${Purple}Changes disregarded.${NC}" && QUIT ;; [yY]* ) sudo -k git restore . && echo -e "${IPurple}Quitting nixie. ${Purple}Changes disregarded.${NC}" && QUIT ;;
*) echo -e -n "[ ${Red}cancelled ${NC}] " && CHOOSE_CASE ;; *) echo -e -n "[ ${Yellow}cancelled ${NC}] " && CHOOSE_CASE ;;
esac esac
} }
# Script
pushd /etc/nixos > /dev/null pushd /etc/nixos > /dev/null
echo -e "${IPurple}Running pixie. ${Purple}You might be asked to input the root password.${NC}" echo -e "${IPurple}Running pixie. ${Purple}You might be asked to input the root password.${NC}"
@ -97,6 +97,6 @@ sudo echo -n
echo -e "${IPurple}Pulling from origin...${NC}" echo -e "${IPurple}Pulling from origin...${NC}"
sudo git pull sudo git pull
EDIT CHOOSE_CASE
QUIT QUIT