From 16fcb9674a71220313f91446e0c259bce5c20f0f Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sun, 24 Dec 2023 20:41:21 +1100 Subject: [PATCH] home-environment: fix incompatible profile error This fixes the error: error: profile '/nix/var/nix/profiles/per-user/enzime/profile' is incompatible with 'nix-env'; please use 'nix profile' instead --- modules/home-environment.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 03e32c087..e4b2ebbee 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -585,11 +585,15 @@ in if config.submoduleSupport.externalPackageInstall then '' - if [[ -e ${cfg.profileDirectory}/manifest.json ]] ; then + # We don't use `cfg.profileDirectory` here because it defaults to + # `/etc/profiles/per-user/` which is constructed by NixOS or + # 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 nix profile list \ | { grep 'home-manager-path$' || test $? = 1; } \ | cut -d ' ' -f 4 \ - | xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG + | xargs -rt $DRY_RUN_CMD nix profile remove $VERBOSE_ARG else if nix-env -q | grep '^home-manager-path$'; then $DRY_RUN_CMD nix-env -e home-manager-path