Handle use-xdg-base-directories for profile link#7929
Handle use-xdg-base-directories for profile link#7929balsoft wants to merge 1 commit intoNixOS:masterfrom
Conversation
2fef0f4 to
a2e6820
Compare
scripts/nix-profile-daemon.sh.in
Outdated
| printf "$warning Profiles do not match. You should manually migrate from %s to %s.\n" "$NIX_LINK" "$NIX_LINK_NEW" 1>&2 | ||
| fi | ||
| NIX_LINK="$HOME/.nix-profile" | ||
| if [[ $(PATH="$PATH:@localstatedir@/nix/profiles/default/bin" nix show-config use-xdg-base-directories) == true ]]; then |
There was a problem hiding this comment.
Ideally we shouldn't call nix (or any non-shell builtin) inside profile scripts since it slows down every shell invocation...
There was a problem hiding this comment.
Hm, true. Each invocation of nix show-config use-xdg-base-directories takes about 17 ms, which is quite a lot :(
There was a problem hiding this comment.
Would it be an acceptable compromise to just add both locations to $PATH then?
There was a problem hiding this comment.
I guess 17 ms is fine for login shells. That's probably preferrable over polluting $PATH with non-existent paths.
There was a problem hiding this comment.
Yeah I think it is fine for login shells.
a2e6820 to
9bedfd6
Compare
cole-h
left a comment
There was a problem hiding this comment.
I'm slightly meh on the idea of needing to invoke nix on shell startup (even if it's "only" for login shells), but if this is decided as the accepted solution, we need to make sure to pass --extra-experimental-features (or use a legacy CLI invocation, if one exists...?).
9bedfd6 to
56df2a4
Compare
|
Triaged in the Nix team meeting 2023-03-31:
|
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
Discussed in the Nix team meeting 2023-04-03:
|
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
Re-discussed during the Nix team meeting. Since this isn't urgent any more (a less-correct but acceptable fix having being merged) @Ericson2314 will try an alternative approach that doesn't involve calling Discussion log |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Motivation
#5588 broke the
PATHsetting logic inprofile.sh: #5588 (comment)This PR attempts to fix that by checking the
use-xdg-base-directoriesconfig option and deciding whether to use the XDG-compliant location or the old one based on that.Context
#5588 introduced a
use-xdg-base-directoriesoption which, when enabled, makes Nix use the new locations instead of~/.nix-profile,~/.nix-channeland~/.nix-defexpr.However, the accompanying
profile.shchange was not quite correct: it chose the new location if the old one didn't exist.Checking the
use-xdg-base-directoriesshould enable us to handle this properly (only adding the relevant profile link to$PATH).Checklist for maintainers
Maintainers: tick if completed or explain if not relevant
tests/**.shsrc/*/teststests/nixos/*