diff --git a/flake.lock b/flake.lock index d92c70b..b1f8af8 100644 --- a/flake.lock +++ b/flake.lock @@ -484,11 +484,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1749246388, - "narHash": "sha256-Dwwn4G27Tb3ErlErOThqXI+bIJ3usoHogzmFE20XgBw=", + "lastModified": 1749272342, + "narHash": "sha256-EGEAvVv3wp+dWeagxePwVNpMTx+dmR//VlZB4vWu2oA=", "owner": "nix-community", "repo": "NUR", - "rev": "b867f29b2dd10e29477a15aebc4c3f6354ca723d", + "rev": "aff4128eb3e712d2a592faacc883f3b0ea86c9fd", "type": "github" }, "original": { diff --git a/home/scripts/nixupdate b/home/scripts/nixupdate new file mode 100755 index 0000000..f1d93c5 --- /dev/null +++ b/home/scripts/nixupdate @@ -0,0 +1,36 @@ + +#!/usr/bin/env bash +# +# NixOS update and rebuild script +# +# original by 0atman: https://gist.github.com/0atman/1a5133b842f929ba4c1e195ee67599d5 + +set -e + +pushd ~/nix-config + +nix flake update + +if git diff --quiet; then + echo "No changes detected, exiting." + popd + exit 0 +fi + +alejandra . &>/dev/null \ + || ( alejandra . ; echo "formatting failed!" && exit 1) + +git diff -U0 + +echo "NixOS rebuilding..." + +sudo nixos-rebuild switch --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 \ No newline at end of file