From a544d3634010784886e157f2f904b1d468713699 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Tue, 15 Sep 2026 04:34:43 +0530 Subject: fix(system/nix-update): unstaging properly on exceptions --- modules/system/nix-update/nix-update.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'modules/system/nix-update/nix-update.sh') diff --git a/modules/system/nix-update/nix-update.sh b/modules/system/nix-update/nix-update.sh index 943a1d8..bacfc20 100644 --- a/modules/system/nix-update/nix-update.sh +++ b/modules/system/nix-update/nix-update.sh @@ -69,6 +69,8 @@ update_home_manager() { info "Staging users/arpit/private.nix..." git add users/arpit/private.nix -f + trap 'git rm --cached users/arpit/private.nix >/dev/null 2>&1 || true' EXIT INT TERM HUP + if [[ "$ONLY_SWITCH" == false ]]; then info "Running nix flake update..." nix flake update @@ -82,6 +84,8 @@ update_home_manager() { info "Unstaging users/arpit/private.nix..." git rm --cached users/arpit/private.nix + trap - EXIT INT TERM HUP + info "home-manager update complete" } @@ -93,6 +97,8 @@ update_nixos() { info "Staging hardware-configuration.nix..." git add hardware-configuration.nix -f + trap 'git rm --cached hardware-configuration.nix >/dev/null 2>&1 || true' EXIT INT TERM HUP + if [[ "$ONLY_SWITCH" == false ]]; then info "Running nix flake update..." nix flake update @@ -106,6 +112,8 @@ update_nixos() { info "Unstaging hardware-configuration.nix..." git rm --cached hardware-configuration.nix + trap - EXIT INT TERM HUP + info "NixOS update complete" } @@ -122,4 +130,4 @@ case "$TARGET" in update_nixos update_home_manager ;; -esac \ No newline at end of file +esac -- cgit v1.2.3