-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle use-xdg-base-directories for profile link #7929
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be an acceptable compromise to just add both locations to $PATH
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it is fine for login shells.
a2e6820
to
9bedfd6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: https://discourse.nixos.org/t/2023-03-31-nix-team-meeting-minutes-45/27002/1 |
Discussed in the Nix team meeting 2023-04-03:
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-04-03-nix-team-meeting-minutes-46/27008/1 |
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: https://discourse.nixos.org/t/2023-07-24-nix-team-meeting-minutes-74/31116/1 |
Motivation
#5588 broke the
PATH
setting logic inprofile.sh
: #5588 (comment)This PR attempts to fix that by checking the
use-xdg-base-directories
config option and deciding whether to use the XDG-compliant location or the old one based on that.Context
#5588 introduced a
use-xdg-base-directories
option which, when enabled, makes Nix use the new locations instead of~/.nix-profile
,~/.nix-channel
and~/.nix-defexpr
.However, the accompanying
profile.sh
change was not quite correct: it chose the new location if the old one didn't exist.Checking the
use-xdg-base-directories
should 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/**.sh
src/*/tests
tests/nixos/*