1
Fork 0
mirror of https://github.com/RGBCube/ncc synced 2025-07-29 19:17:45 +00:00

Remove collect garbage option from rebuild script

This commit is contained in:
RGBCube 2023-11-08 08:38:38 +03:00
parent 9ec2173a9e
commit 5e1684a6c1
No known key found for this signature in database

View file

@ -1,34 +1,15 @@
#!/bin/sh
if [[ $1 == "-h" || $1 == "--help" ]]; then
echo "Usage: $0 [-h | --help] [-c | --clean-garbage] [machine]"
echo "Usage: $0 [-h | --help] [machine]"
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
fi
fi
machine=$1
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
nix-shell --packages git --command "sudo nixos-rebuild switch --flake .#$machine" || exit 1
if [[ $clean_garbage =~ ^[Yy]$ ]]; then
sudo nix-collect-garbage --delete-old
fi
nix-shell --packages git --command "sudo nixos-rebuild switch --flake .#$machine"