nixos-config/rebuild

33 lines
730 B
Plaintext
Raw Permalink Normal View History

2024-02-27 04:51:16 +00:00
#!/usr/bin/env bash
# A rebuild script that commits on a successful build
set -e
# cd to your config dir
pushd ~/nixos/
# Edit your config
nvim configuration.nix
# Autoformat your nix files
# alejandra . &>/dev/null
# 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 witih the generation metadata
git commit -am "$current"
# Back to where you were
popd
# Notify all OK!
notify-send -e "NixOS Rebuilt OK!" --icon=software-update-available