1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-30 11:37:44 +00:00

Make rebuild.sh better (see commit desc)

* Asks to clean garbage before long rebuild
* Simpler machine selection, DRY
This commit is contained in:
RGBCube 2023-05-27 21:50:27 +03:00
parent ea81b8d03e
commit cda9481abe
No known key found for this signature in database

View file

@ -5,28 +5,30 @@ if [[ $1 == "-h" || $1 == "--help" ]]; then
exit
fi
machine=
if [[ $1 != "" ]]; then
if [[ $1 != "-c" && $1 != "--clean-garbage" ]]; then
# Use the first argument if it exists and is not clean-garbage.
machine=$1
elif [[ $2 != "" ]]; then
# Use the second argument if the first argument is clean-garbage and the second argument exists.
machine=$2
else
read -p "What machine would you want to build? [$(ls --format=commas machines)]: " machine
fi
else
read -p "What machine would you want to build? [$(ls --format=commas machines)]: " machine
fi
sudo true
if [[ $machine == "" ]]; then
available_machines=$(ls --format=commas machines)
read -p "What machine would you like to build? (Possible options: $available_machines): " machine
fi
if [[ $1 == "-c" && $1 == "--clean-garbage" ]]; then
clean_garbage=y
else
read -p "Clean garbage? [Y/N]: " clean_garbage
fi
sudo nixos-rebuild switch --impure --flake .#$machine || exit 1
if [[ $1 != "-c" && $1 != "--clean-garbage" ]]; then
read -p "Clean garbage? [Y/N]: " clean_garbage
if [[ $clean_garbage =~ ^[Yy]$ ]]; then
sudo nix-collect-garbage -d
fi
else
sudo nix-collect-garbage -d
fi