From 190c6f46090a62ad025828bd8e16799d8fcdab1e Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Mon, 22 Jan 2024 22:40:55 +0100 Subject: [PATCH] home-manager: avoid running empty `nix profile remove` We only want to run `nix profile remove` if there is actually anything to remove. --- modules/files.nix | 2 +- modules/lib-bash/activation-init.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/files.nix b/modules/files.nix index 9bbdb5b71..c0d563c26 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -268,7 +268,7 @@ in # `nix profile remove '.*' --profile "$genProfilePath"` was not working, so here is a workaround: nix profile list --profile "$genProfilePath" \ | cut -d ' ' -f 4 \ - | xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG --profile "$genProfilePath" + | xargs -rt $DRY_RUN_CMD nix profile remove $VERBOSE_ARG --profile "$genProfilePath" run nix profile install $VERBOSE_ARG --profile "$genProfilePath" "$newGenPath" else run nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath" diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index aff833cb9..773abcd34 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -112,7 +112,7 @@ function nixProfileRemove() { # nix-darwin and won't require uninstalling `home-manager-path`. if [[ -e $HOME/.nix-profile/manifest.json \ || -e ${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/manifest.json ]] ; then - nixProfileList "$1" | xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG + nixProfileList "$1" | xargs -rt $DRY_RUN_CMD nix profile remove $VERBOSE_ARG else if nix-env -q | grep -q "^$1$"; then run --silence nix-env -e "$1"