mirror of
https://git.pionaiki.com/marta/nixie.git
synced 2025-10-09 05:47:21 +00:00
Flow + Formatting 2
This commit is contained in:
parent
f4d574f578
commit
ca947b14a7
1 changed files with 37 additions and 23 deletions
60
nixie
60
nixie
|
@ -10,18 +10,14 @@ QUIT () {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
QUIT1 () {
|
|
||||||
popd > /dev/null
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
CHOOSE_CASE () {
|
CHOOSE_CASE () {
|
||||||
echo -e -n "${IPurple}What do you want to do? ${Purple}Edit/reBuild/reView/Restore/Quit (e/b/v/r/q): ${NC}"
|
echo -e -n "${IPurple}What do you want to do? ${Purple}Edit/reBuild/Update/reView/Restore/Quit (e/b/u/v/r/q): ${NC}"
|
||||||
|
|
||||||
read CHOICE
|
read CHOICE
|
||||||
case $CHOICE in
|
case $CHOICE in
|
||||||
[eE]* ) EDIT ;;
|
[eE]* ) EDIT ;;
|
||||||
[bB]* ) BUILD ;;
|
[bB]* ) BUILD ;;
|
||||||
|
[uU]* ) UPDATE ;;
|
||||||
[vV]* ) REVIEW ;;
|
[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 ;;
|
||||||
|
@ -29,40 +25,61 @@ CHOOSE_CASE () {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDIT () {
|
||||||
|
echo -e "${IPurple}Opening editor...${NC}"
|
||||||
|
sudo vim .
|
||||||
|
sudo git diff --stat
|
||||||
|
CHOOSE_CASE
|
||||||
|
}
|
||||||
|
|
||||||
BUILD () {
|
BUILD () {
|
||||||
echo -e "${IPurple}This will rebuild NixOS, and if there are no errors, commit changes to git."
|
echo -e "${IPurple}Continuing will rebuild NixOS and commit changes to git."
|
||||||
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 "[ ${Yellow}cancelled ${NC}] " && CHOOSE_CASE ;;
|
[nN]* ) echo -e -n "Cancelled " ;;
|
||||||
*)
|
*)
|
||||||
sudo git add .
|
sudo git add .
|
||||||
echo -e "${IPurple}Rebuilding NixOS...${NC}"
|
echo -e "${IPurple}Rebuilding NixOS...${NC}"
|
||||||
sudo nixos-rebuild switch
|
sudo nixos-rebuild switch
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "[ ${Red}error ${NC}] ${Red}Rebuilding NixOS failed.${NC}"
|
echo -e "[ ${Red}error ${NC}] ${Red}Rebuilding NixOS failed.${NC}"
|
||||||
QUIT1
|
CHOOSE_CASE
|
||||||
|
QUIT
|
||||||
fi
|
fi
|
||||||
echo -e "${IPurple}Committing the changes...${NC}"
|
echo -e "${IPurple}Committing the changes...${NC}"
|
||||||
sudo git commit --no-status -am "$(sudo nixos-rebuild list-generations | grep current | sed 's/ .*//')"
|
sudo git commit --no-status -am "$(sudo nixos-rebuild list-generations | grep current | sed 's/ .*//')"
|
||||||
echo -e "${IPurple}System rebuilt, configuration commited.${NC}"
|
echo -e "${IPurple}System rebuilt, configuration commited.${NC}"
|
||||||
echo -e -n "${IPurple}Push changes? ${Purple}Yes/Squash/No (y/S/n): ${NC}"
|
echo -e -n "${IPurple}Push changes? ${Purple}Yes/Squash/No (y/s/N): ${NC}"
|
||||||
read CHOICE
|
read CHOICE
|
||||||
case $CHOICE in
|
case $CHOICE in
|
||||||
[yY]* )
|
[yY]* )
|
||||||
echo -e "${IPurple}Pushing...${NC}"
|
echo -e "${IPurple}Pushing...${NC}"
|
||||||
sudo git push
|
sudo git push
|
||||||
;;
|
;;
|
||||||
[nN]* ) echo -e -n "${IPurple}Not pushing changes. ${NC}" ;;
|
[sS]* )
|
||||||
*)
|
|
||||||
echo -e "${IPurple}Squashing...${NC}"
|
echo -e "${IPurple}Squashing...${NC}"
|
||||||
sudo git rebase origin/HEAD
|
sudo git rebase origin/HEAD
|
||||||
echo -e "${IPurple}Pushing...${NC}"
|
echo -e "${IPurple}Pushing...${NC}"
|
||||||
sudo git push
|
sudo git push
|
||||||
;;
|
;;
|
||||||
|
*) echo -e -n "Not pushing changes. " ;;
|
||||||
esac
|
esac
|
||||||
echo -e "${IPurple}Quitting nixie.${NC}"
|
;;
|
||||||
QUIT
|
esac
|
||||||
|
CHOOSE_CASE
|
||||||
|
}
|
||||||
|
|
||||||
|
UPDATE () {
|
||||||
|
echo -e -n "${IPurple}Are you sure you want to update flake.lock? ${Purple}Yes/No (Y/n): ${NC}"
|
||||||
|
read CHOICE
|
||||||
|
case $CHOICE in
|
||||||
|
[nN]* ) echo -e -n "Cancelled " && CHOOSE_CASE ;;
|
||||||
|
*)
|
||||||
|
echo -e "${IPurple}Updating flake.lock..."
|
||||||
|
sudo nix flake update
|
||||||
|
echo -e -n "Updated. "
|
||||||
|
BUILD
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -73,21 +90,18 @@ REVIEW () {
|
||||||
CHOOSE_CASE
|
CHOOSE_CASE
|
||||||
}
|
}
|
||||||
|
|
||||||
EDIT () {
|
|
||||||
echo -e "${IPurple}Opening editor...${NC}"
|
|
||||||
sudo vim .
|
|
||||||
sudo git diff --stat
|
|
||||||
CHOOSE_CASE
|
|
||||||
}
|
|
||||||
|
|
||||||
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]* )
|
||||||
*) echo -e -n "[ ${Yellow}cancelled ${NC}] " && CHOOSE_CASE ;;
|
sudo -k git restore .
|
||||||
|
echo -e -n "Changes disregarded. "
|
||||||
|
;;
|
||||||
|
*) echo -e -n "Cancelled. " ;;
|
||||||
esac
|
esac
|
||||||
|
CHOOSE_CASE
|
||||||
}
|
}
|
||||||
|
|
||||||
pushd /etc/nixos > /dev/null
|
pushd /etc/nixos > /dev/null
|
||||||
|
|
Loading…
Add table
Reference in a new issue