aboutsummaryrefslogtreecommitdiffstats
path: root/modules/system
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar@gmail.com>2026-09-15 04:34:43 +0530
committerArpit Chakladar <arpitchakladar@gmail.com>2026-09-15 04:34:43 +0530
commita544d3634010784886e157f2f904b1d468713699 (patch)
treea9ca2e3183c0edef05f035a1f3fffbbfe6e2af90 /modules/system
parent61d7d04c916f1bc84058cc6043f14006522a9ede (diff)
downloadhome-manager-config-a544d3634010784886e157f2f904b1d468713699.tar.gz
home-manager-config-a544d3634010784886e157f2f904b1d468713699.zip
fix(system/nix-update): unstaging properly on exceptions
Diffstat (limited to 'modules/system')
-rw-r--r--modules/system/nix-update/nix-update.sh10
1 files changed, 9 insertions, 1 deletions
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