-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebuild
executable file
·25 lines (25 loc) · 988 Bytes
/
rebuild
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
CURRENT_DIR=$(echo $PWD)
OS=$(uname -s)
SUBOS=$(cat /etc/*-release | grep DISTRIB_ID | sed s/DISTRIB_ID=//)
HOST=$(hostname)
nvim .
for file in $(find . -name "*.nix"); do
alejandra $file &>/dev/null
done
git diff *.nix
if [ "$OS" = "Darwin" ]; then
echo "Nix Darwin Rebuilding..."
darwin-rebuild switch --flake .#jacob-germany &>~/.logs/latest-rebuild.log || (cat ~/.logs/latest-rebuild.log | grep --color error && false)
gen="Nix Darwin: $(darwin-rebuild --list-generations | sed -n '$p' | awk '{print $1}')"
elif [ "$SUBOS" = nixos ]; then
echo "NixOS Rebuilding..."
nh os switch .
gen="NixOS: $(nix-env --list-generations | sed -n '$p' | awk '{print $1}')"
else
echo "Home-Manager Rebuilding..."
home-manager build switch &>~/.logs/home-manager-rebuild.log || (cat ~/.logs/latest-rebuild.log | grep --color error && false)
gen="Home Manager: $(home-manager generations | sed -n '1p' | awk '{print $5}')"
fi
git commit -am "Rebuild: $gen"
cd $CURRENT_DIR