2024-03-01 15:22:49 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# A rebuild script that commits on a successful build
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# cd to your config dir
|
|
|
|
pushd ~/dotfiles/nixos/
|
|
|
|
|
|
|
|
# Edit your config
|
2024-03-03 12:26:53 +01:00
|
|
|
$EDITOR
|
2024-03-01 15:22:49 +01:00
|
|
|
|
|
|
|
# Autoformat your nix files
|
2024-03-01 16:45:06 +01:00
|
|
|
alejandra . #&>/dev/null
|
2024-03-01 15:22:49 +01:00
|
|
|
|
|
|
|
# Shows your changes
|
|
|
|
git diff -U0 *.nix
|
|
|
|
|
|
|
|
echo "NixOS Rebuilding..."
|
|
|
|
|
|
|
|
# Rebuild, output simplified errors, log trackebacks
|
|
|
|
sudo nixos-rebuild switch &>nixos-switch.log || (cat nixos-switch.log | grep --color error && false)
|
|
|
|
|
|
|
|
# Get current generation metadata
|
|
|
|
current=$(nixos-rebuild list-generations | grep current)
|
|
|
|
|
|
|
|
# Commit all changes with the gereation metadata
|
|
|
|
git commit -am "$current"
|
|
|
|
|
|
|
|
# Back to where you were
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Notify all OK!
|
|
|
|
notify-send -e "NixOS Rebuilt OK!" --icon=software-update-available
|