commit
This commit is contained in:
29
rebuild.sh
Executable file
29
rebuild.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if git diff --quiet '*.nix'; then
|
||||
echo "No changes detected, exiting"
|
||||
popd
|
||||
exit 0
|
||||
fi
|
||||
|
||||
alejandra . &>/dev/null ||
|
||||
(
|
||||
alejandra .
|
||||
echo "formatting failed!" && exit 1
|
||||
)
|
||||
|
||||
git diff -U0 '*.nix'
|
||||
|
||||
echo "NixOS rebuilding..."
|
||||
|
||||
sudo nixos-rebuild switch --impure --flake . &>nixos-switch.log || (cat nixos-switch.log | grep --color error && exit 1)
|
||||
|
||||
current=$(nixos-rebuild list-generations | grep current)
|
||||
|
||||
git commit -am "$current"
|
||||
|
||||
popd
|
||||
|
||||
notify-send -e "NixOS Rebuilt OK!" --icon=software-update-available
|
||||
Reference in New Issue
Block a user