From b989db5900df4bd1a786f8afd8063dae09d89a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Silva?= <123550+andresilva@users.noreply.github.com> Date: Mon, 15 Jan 2024 16:25:23 +0000 Subject: [PATCH] home-manager: check profile exists in nixProfileRemove --- modules/lib-bash/activation-init.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/lib-bash/activation-init.sh b/modules/lib-bash/activation-init.sh index c691bf7e2..0924c637e 100755 --- a/modules/lib-bash/activation-init.sh +++ b/modules/lib-bash/activation-init.sh @@ -114,7 +114,9 @@ function nixProfileRemove() { || -e ${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/manifest.json ]] ; then nixProfileList "$1" | xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG else - $DRY_RUN_CMD nix-env -e "$1" > $DRY_RUN_NULL 2>&1 + if nix-env -q | grep -q "^$1$"; then + $DRY_RUN_CMD nix-env -e "$1" > $DRY_RUN_NULL 2>&1 + fi fi }