diff --git a/hosts/framework/home.nix b/hosts/framework/home.nix index bc9fa93..0bee8a2 100644 --- a/hosts/framework/home.nix +++ b/hosts/framework/home.nix @@ -22,7 +22,7 @@ # The home.packages option allows you to install Nix packages into your # environment. - home.packages = [ + home.packages = with pkgs; [ # # Adds the 'hello' command to your environment. It prints a friendly # # "Hello, world!" when run. # pkgs.hello @@ -39,6 +39,7 @@ # (pkgs.writeShellScriptBin "my-hello" '' # echo "Hello, ${config.home.username}!" # '') + (writeShellScriptBin "updateNix" (builtins.readFile ../../update.sh)) ]; programs.git = { enable = true; diff --git a/modules/nixos/nixUpdate.nix b/modules/nixos/nixUpdate.nix deleted file mode 100644 index 55018c6..0000000 --- a/modules/nixos/nixUpdate.nix +++ /dev/null @@ -1,15 +0,0 @@ -with import {}; - writeShellScriptBin "nixUpdate" '' - set -e - - - pushd ~/nixos/ - - # if git diff --quiet '*.nix'; then - # echo "no changes" - # popd - # exit 0 - # fi - - - '' diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..9509499 --- /dev/null +++ b/update.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +set -e + + +pushd ~/nixos/ + +alejandra . &>/dev/null \ + || (alejandra . ; echo "formatting failed!" && exit 1) + +echo "Rebuilding" +sudo nixos-rebuild switch --upgrade --flake . + +current=$(nixos-rebuild list-generations | grep current) + +if git diff --quiet '*.nix'; then + popd + notify-send -e "Nixos updated with no config changes" --icon=software-update-avaiable +fi + +git commit -am "$current" +git push + +popd + +notify-send -e "Nixos updated and pushed to git" --icon=software-update-avaiable +