home-manager: improve nix profile detection
If `nix.settings.use-xdg-base-directories` is true, the `~/.nix-profile` directory may not exist, and `home.profileDirectory` should be checked instead. Co-authored-by: Bruno BELANYI <bruno@belanyi.fr>
This commit is contained in:
parent
e9b9ecef42
commit
a2e592cc49
|
@ -29,7 +29,9 @@ function removeByName() {
|
|||
}
|
||||
|
||||
function setNixProfileCommands() {
|
||||
if [[ -e $HOME/.nix-profile/manifest.json ]] ; then
|
||||
if [[ -e $HOME/.nix-profile/manifest.json \
|
||||
|| -e ${XDG_STATE_HOME:-$HOME/.local/state}/nix/profile/manifest.json ]] ; then
|
||||
|
||||
LIST_OUTPATH_CMD="nix profile list"
|
||||
REMOVE_CMD="removeByName"
|
||||
else
|
||||
|
@ -406,6 +408,10 @@ $xdgVars
|
|||
#
|
||||
# or
|
||||
#
|
||||
# ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
# or
|
||||
#
|
||||
# /etc/profiles/per-user/$USER/etc/profile.d/hm-session-vars.sh
|
||||
#
|
||||
home.sessionVariables = {
|
||||
|
|
|
@ -175,7 +175,7 @@ in
|
|||
done automatically if the shell configuration is managed by Home
|
||||
Manager. If not, then you must source the
|
||||
|
||||
~/.nix-profile/etc/profile.d/hm-session-vars.sh
|
||||
${cfg.profileDirectory}/etc/profile.d/hm-session-vars.sh
|
||||
|
||||
file yourself.
|
||||
'')
|
||||
|
@ -585,7 +585,7 @@ in
|
|||
if config.submoduleSupport.externalPackageInstall
|
||||
then
|
||||
''
|
||||
if [[ -e $HOME/.nix-profile/manifest.json ]] ; then
|
||||
if [[ -e ${cfg.profileDirectory}/manifest.json ]] ; then
|
||||
nix profile list \
|
||||
| { grep 'home-manager-path$' || test $? = 1; } \
|
||||
| cut -d ' ' -f 4 \
|
||||
|
@ -623,7 +623,7 @@ in
|
|||
$DRY_RUN_CMD $oldNix profile install $1
|
||||
}
|
||||
|
||||
if [[ -e $HOME/.nix-profile/manifest.json ]] ; then
|
||||
if [[ -e ${cfg.profileDirectory}/manifest.json ]] ; then
|
||||
INSTALL_CMD="nix profile install"
|
||||
INSTALL_CMD_ACTUAL="nixReplaceProfile"
|
||||
LIST_CMD="nix profile list"
|
||||
|
|
Loading…
Reference in a new issue