From a91ed8f66d2a95c5a751fedca790b146e31500a4 Mon Sep 17 00:00:00 2001 From: Gustav Bruhn Date: Tue, 18 Mar 2025 20:12:47 +0100 Subject: [PATCH] 17 current 2025-03-18 20:12:11 25.05.20250315.c80f6a7 6.12.19 * --- hosts/framework/home.nix | 3 ++- modules/nixos/nixUpdate.nix | 15 --------------- update.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 16 deletions(-) delete mode 100644 modules/nixos/nixUpdate.nix create mode 100644 update.sh 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 +