From 5e7d6d1214411d010403fa78c61e5da261ab9d80 Mon Sep 17 00:00:00 2001 From: Tobias Happ Date: Fri, 18 Nov 2022 20:58:12 +0100 Subject: [PATCH] environment.path: fix installation with nix profile Manual removal and installation as two non-atomical steps is required because of https://github.com/NixOS/nix/issues/6349. --- modules/environment/path.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/environment/path.nix b/modules/environment/path.nix index 6a8d80b..123fbb4 100644 --- a/modules/environment/path.nix +++ b/modules/environment/path.nix @@ -38,7 +38,19 @@ in build.activation.installPackages = '' if [[ -e "${config.user.home}/.nix-profile/manifest.json" ]]; then - $DRY_RUN_CMD nix profile install ${cfg.path} + # manual removal and installation as two non-atomical steps is required + # because of https://github.com/NixOS/nix/issues/6349 + + nix_previous="$(command -v nix)" + + nix profile list \ + | grep 'nix-on-droid-path$' \ + | cut -d ' ' -f 4 \ + | xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG + + $DRY_RUN_CMD $nix_previous profile install ${cfg.path} + + unset nix_previous else $DRY_RUN_CMD nix-env --install ${cfg.path} fi