mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
home-environment: fix activation on new style profiles
When using the new style profiles we get conflicts when trying to
replace the old `home-path` derivation. To avoid this conflict we
delete the old `home-path` before the install.
Unfortunately, `nix profile` does not yet have a equivalent for
`nix-env --set` and we have to do this hackish workaround. See
https://github.com/NixOS/nix/issues/6349
for the associated issue in Nix.
Fixes #2848
(cherry picked from commit ccc9164b76
)
This commit is contained in:
parent
87d55517f6
commit
071e28c869
1 changed files with 17 additions and 2 deletions
|
@ -592,22 +592,37 @@ in
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
|
function nixReplaceProfile() {
|
||||||
|
local oldNix="$(which nix)"
|
||||||
|
|
||||||
|
nix profile list \
|
||||||
|
| { grep 'home-manager-path$' || test $? = 1; } \
|
||||||
|
| awk -F ' ' '{ print $4 }' \
|
||||||
|
| cut -d ' ' -f 4 \
|
||||||
|
| xargs -t $DRY_RUN_CMD nix profile remove $VERBOSE_ARG
|
||||||
|
|
||||||
|
$DRY_RUN_CMD $oldNix profile install $1
|
||||||
|
}
|
||||||
|
|
||||||
if [[ -e "$nixProfilePath"/manifest.json ]] ; then
|
if [[ -e "$nixProfilePath"/manifest.json ]] ; then
|
||||||
INSTALL_CMD="nix profile install"
|
INSTALL_CMD="nix profile install"
|
||||||
|
INSTALL_CMD_ACTUAL="nixReplaceProfile"
|
||||||
LIST_CMD="nix profile list"
|
LIST_CMD="nix profile list"
|
||||||
REMOVE_CMD_SYNTAX='nix profile remove {number | store path}'
|
REMOVE_CMD_SYNTAX='nix profile remove {number | store path}'
|
||||||
else
|
else
|
||||||
INSTALL_CMD="nix-env -i"
|
INSTALL_CMD="nix-env -i"
|
||||||
|
INSTALL_CMD_ACTUAL="$DRY_RUN_CMD nix-env -i"
|
||||||
LIST_CMD="nix-env -q"
|
LIST_CMD="nix-env -q"
|
||||||
REMOVE_CMD_SYNTAX='nix-env -e {package name}'
|
REMOVE_CMD_SYNTAX='nix-env -e {package name}'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $DRY_RUN_CMD $INSTALL_CMD ${cfg.path} ; then
|
if ! $INSTALL_CMD_ACTUAL ${cfg.path} ; then
|
||||||
echo
|
echo
|
||||||
_iError $'Oops, Nix failed to install your new Home Manager profile!\n\nPerhaps there is a conflict with a package that was installed using\n"%s"? Try running\n\n %s\n\nand if there is a conflicting package you can remove it with\n\n %s\n\nThen try activating your Home Manager configuration again.' "$INSTALL_CMD" "$LIST_CMD" "$REMOVE_CMD_SYNTAX"
|
_iError $'Oops, Nix failed to install your new Home Manager profile!\n\nPerhaps there is a conflict with a package that was installed using\n"%s"? Try running\n\n %s\n\nand if there is a conflicting package you can remove it with\n\n %s\n\nThen try activating your Home Manager configuration again.' "$INSTALL_CMD" "$LIST_CMD" "$REMOVE_CMD_SYNTAX"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
unset INSTALL_CMD LIST_CMD REMOVE_CMD_SYNTAX
|
unset -f nixReplaceProfile
|
||||||
|
unset INSTALL_CMD INSTALL_CMD_ACTUAL LIST_CMD REMOVE_CMD_SYNTAX
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue