improved rebuild script

This commit is contained in:
joy 2024-10-18 10:48:54 +02:00
parent 1ad690b5a7
commit 3951cee6db

View file

@ -2,22 +2,30 @@
current_dir=$(pwd) current_dir=$(pwd)
cd ~/nix cd ~/nix || exit
git add . git fetch
alejandra . if git diff --quiet HEAD..origin/main; then
echo "No changes detected in the remote. Proceeding with rebuild..."
hostname=$(hostname) git add .
if echo "$hostname" | grep -q 'desktop'; then hostname=$(hostname)
doas nixos-rebuild switch --flake ~/nix/#desktop
elif echo "$hostname" | grep -q 'laptop'; then if echo "$hostname" | grep -q 'desktop'; then
doas nixos-rebuild switch --flake ~/nix/#laptop doas nixos-rebuild switch --flake ~/nix/#desktop
elif echo "$hostname" | grep -q 'server'; then elif echo "$hostname" | grep -q 'laptop'; then
doas nixos-rebuild switch --flake ~/nix/#server doas nixos-rebuild switch --flake ~/nix/#laptop
elif echo "$hostname" | grep -q 'localhost'; then elif echo "$hostname" | grep -q 'server'; then
nix-on-droid switch --flake ~/nix doas nixos-rebuild switch --flake ~/nix/#server
elif echo "$hostname" | grep -q 'localhost'; then
nix-on-droid switch --flake ~/nix
fi
else
echo "Changes detected in the remote. Stopping execution."
git diff HEAD..origin/main
exit 1
fi fi
cd "$current_dir" cd "$current_dir" || exit