31 lines
431 B
Bash
31 lines
431 B
Bash
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
|
|
pushd ~/nixos/
|
|
git add .
|
|
alejandra . &>/dev/null \
|
|
|| (alejandra . ; echo "formatting failed!" && exit 1)
|
|
|
|
echo "Updating flake"
|
|
nix flake update
|
|
|
|
|
|
echo "Rebuilding"
|
|
sudo nixos-rebuild switch --upgrade --flake .
|
|
|
|
current=$(nixos-rebuild list-generations | grep current)
|
|
git restore --staged .
|
|
|
|
|
|
if git diff --quiet '*.nix'; then
|
|
popd
|
|
exit 0
|
|
fi
|
|
git add .
|
|
|
|
git commit -am "$current"
|
|
git push
|
|
|
|
popd
|