From df50c9715da93614aa921aa84d0ca592a17c4ce3 Mon Sep 17 00:00:00 2001 From: Jacob Bachmann Date: Tue, 30 Jan 2024 20:07:27 +0100 Subject: [PATCH] feat(scripts/nix-update): cleanup temp dir --- users/gandalf/modules/scripts/nix-update.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/users/gandalf/modules/scripts/nix-update.nix b/users/gandalf/modules/scripts/nix-update.nix index 52f268b..c115359 100644 --- a/users/gandalf/modules/scripts/nix-update.nix +++ b/users/gandalf/modules/scripts/nix-update.nix @@ -6,8 +6,10 @@ pkgs.writeShellScriptBin "nuf" '' green="\e[32m" yellow="\e[33m" white_bold="\e[1;37m" + tmp=$(mktemp -d) function error { + rm -rf tmp echo "" echo -e "''${red}>>> ''${bold}Error''${reset}''${red}: $1''${reset}" exit 1 @@ -18,7 +20,7 @@ pkgs.writeShellScriptBin "nuf" '' echo -e "''${green}>>> Updating flake $FLAKE ...''${reset}" ${nixosConfig.nix.package}/bin/nix flake update --flake "$FLAKE" || error "Updating failed" - cd $(mktemp -d) + cd $tmp echo "" echo -e "''${green}>>> Building configuration ...''${reset}" nixos-rebuild build --flake "$FLAKE" || error "Building failed" @@ -28,6 +30,7 @@ pkgs.writeShellScriptBin "nuf" '' ${pkgs.nvd}/bin/nvd diff /run/current-system result || error "Diff failed" cd - > /dev/null + rm -rf $tmp echo "" echo -e "''${yellow}>>> The new configuration has not been activated.''${reset}"