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.
This commit is contained in:
Tobias Happ 2022-11-18 20:58:12 +01:00
parent 27c206f57a
commit 048b22fe13

View file

@ -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