2024-04-21 19:57:10 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
#Change to change box setup
|
2024-05-27 21:39:29 -04:00
|
|
|
BOX="$(cat .box)"
|
2024-04-21 19:57:10 -04:00
|
|
|
|
|
|
|
pushd ~/nixos/
|
2024-05-25 22:21:28 -04:00
|
|
|
notify(){
|
|
|
|
command -v notify-send > /dev/null
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
return
|
|
|
|
else
|
|
|
|
notify-send "$@"
|
|
|
|
fi
|
|
|
|
}
|
2024-04-21 22:14:09 -04:00
|
|
|
# if git diff --quiet '*.nix' && [[ !( $1 =~ "*force*") ]] then
|
|
|
|
# echo "No changes. Exiting"
|
|
|
|
# # notify-send "No changes. Exiting"
|
|
|
|
# popd
|
|
|
|
# exit 0
|
|
|
|
# fi
|
2024-04-21 19:57:10 -04:00
|
|
|
|
|
|
|
#TODO: Format files
|
|
|
|
#format **
|
|
|
|
|
|
|
|
#show changes
|
|
|
|
git diff -U0 '*.nix'
|
|
|
|
|
|
|
|
echo "Starting build"
|
|
|
|
|
2024-05-25 22:21:28 -04:00
|
|
|
sudo nixos-rebuild switch --flake .#${BOX} &> build.log || (cat build.log | grep --color error && notify "ERROR BUILDING NIX" && exit 1)
|
2024-04-21 19:57:10 -04:00
|
|
|
|
|
|
|
current=$(nixos-rebuild list-generations | grep current)
|
|
|
|
|
|
|
|
git commit -am "${current}"
|
|
|
|
|
|
|
|
popd
|
2024-05-25 22:21:28 -04:00
|
|
|
notify -e "good build" --icon=software-update-okay
|