1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-10 21:29:48 +01:00

home-manager: avoid running empty nix profile remove

We only want to run `nix profile remove` if there is actually anything
to remove.
This commit is contained in:
Robert Helgesson 2024-01-22 22:40:55 +01:00 committed by Mikilio
parent a04f37fab0
commit 62a921c9e0
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
2 changed files with 2 additions and 2 deletions

View file

@ -268,7 +268,7 @@ in
# `nix profile remove '.*' --profile "$genProfilePath"` was not working, so here is a workaround: # `nix profile remove '.*' --profile "$genProfilePath"` was not working, so here is a workaround:
nix profile list --profile "$genProfilePath" \ nix profile list --profile "$genProfilePath" \
| cut -d ' ' -f 4 \ | 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" run nix profile install $VERBOSE_ARG --profile "$genProfilePath" "$newGenPath"
else else
run nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath" run nix-env $VERBOSE_ARG --profile "$genProfilePath" --set "$newGenPath"

View file

@ -112,7 +112,7 @@ function nixProfileRemove() {
# nix-darwin and won't require uninstalling `home-manager-path`. # nix-darwin and won't require uninstalling `home-manager-path`.
if [[ -e $HOME/.nix-profile/manifest.json \ if [[ -e $HOME/.nix-profile/manifest.json \
|| -e ${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/manifest.json ]] ; then || -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 else
if nix-env -q | grep -q "^$1$"; then if nix-env -q | grep -q "^$1$"; then
run --silence nix-env -e "$1" run --silence nix-env -e "$1"