feat(scripts/nix-update): cleanup temp dir

This commit is contained in:
Jacob Bachmann 2024-01-30 20:07:27 +01:00
parent 6bd9b17ed1
commit df50c9715d
Signed by: bchmnn
GPG key ID: 732A612DAD28067D

View file

@ -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}"