Skip to content
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

Global Channels and per-user profiles #7984

Closed
Ericson2314 opened this issue Mar 5, 2023 · 14 comments
Closed

Global Channels and per-user profiles #7984

Ericson2314 opened this issue Mar 5, 2023 · 14 comments

Comments

@Ericson2314
Copy link
Member

Ericson2314 commented Mar 5, 2023

Describe the bug

I ran into trouble installing (a) Nix and then (b) home-manager on my friend's macOS machine. A bunch of similar issues have been reported, but I think this one is slightly different.

The problem is this:

nix/src/libexpr/eval.cc

Lines 2494 to 2495 in 19c1a46

add(settings.nixStateDir + "/profiles/per-user/root/channels/nixpkgs", "nixpkgs");
add(settings.nixStateDir + "/profiles/per-user/root/channels");

these two lines neglect the fact that with the XDG profile dirs, these will instead be in ~root/.local/state/profiles/channels.

Steps To Reproduce

  1. Install Nix 2.14.1 on macOS in multi-user mode
  2. Try to do anything involving <nixpkgs>
  3. get errors because there is no nixpkgs key defined via the Nix Path.

Expected behavior

Global channels are usable with the default (no env var set) Nix path.

nix-env --version output

nix-env (Nix) 2.14.1

Additional context

A simple fix would be to get the the default Nix path to try to look in ~root/.local/state/nix/profiles/channels too, but I don't think that is the right solution. "per user" profiles (channels or otherwise) should be just for that user, which is why it is safe and correct to move them to ~/.local/state/nix/profiles. If channels are to be shared system wide, they are not a per-user concept, even a root user concept. Indeed, root-specific channels should be secret channels just for the root user.

We have precedent of this: the default profile which has long been $nixStateDir/profiles/default not $nixStateDir/profiles/per-user/root precisely for the same reason. We should simply reuse that same solution and have nixStateDir + profiles/default or similar. Neither of these are effected by the XDG stuff because they are not per user, and this is correct.

Priorities

Add 👍 to issues you find important.

@Ericson2314 Ericson2314 added the bug label Mar 5, 2023
@Ericson2314 Ericson2314 changed the title Global Channels and XDG dirs Global Channels and per-user profiles Mar 6, 2023
@fricklerhandwerk
Copy link
Contributor

fricklerhandwerk commented Mar 6, 2023

Edit from @Ericson2314: This is discussion is about the general issue with the release, not this specific channels issue in particular. My fussing with the team agenda caused these notes to land here somewhat inadvertently.


Discussed in the Nix team meeting:

  • @thufschmitt: was pushing for merging that, but it was really hard to have a proper compatibility layer due to how things are set up
    • wondering what's the right thing to do:
      • fix up quickly
      • revert and think it through
      • ignore backwards compatibility
  • @Ericson2314: it's almost there, should change the installer to use the new directories
    • @thufschmitt: not enough to change the installer, need proper backwards compatibility for existing setups
  • @fricklerhandwerk: would veto on ignoring home manager concerns, should rather rethink this
  • @edolstra: this one feels more useful than the XDG one to me
    • if we revert this, would it break people who already rely on the change?
    • @Ericson2314: probably yes
    • @thufschmitt: will think about a fix forward
      • @Ericson2314: flip the default instead of doing more compat
  • no decision

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-03-06-nix-team-meeting-minutes-38/26056/1

@corneliusroemer
Copy link

corneliusroemer commented Mar 7, 2023

I ran into exactly this issue as described, see https://stackoverflow.com/questions/75657834/fresh-install-of-nix-fails-on-m1-mac-error-attribute-nixpkgs-in-selection-pa

Can I suggest a quick fix @fricklerhandwerk? The most affected people by this seem to be people who install for the first time. They will usually use recommended curl -L https://nixos.org/nix/install | sh, this is mentioned everywhere as the way to install.

So why don't you change that install script to download 2.13 until you have figured out a way forward with 2.14?

By the way, one workaround seems to be nix-channel --add https://nixos.org/channels/nixpkgs-unstable, though this may have undesirable side effects. At least it results in an apparently working installation.

@fricklerhandwerk
Copy link
Contributor

fricklerhandwerk commented Mar 7, 2023

Yes, we talked about the more general solution of versioned installers recently, and I'm in favor of this. Need to prioritise it on the team though. @Ericson2314 do we have an issue for that?

@Ericson2314
Copy link
Member Author

@fricklerhandwerk An issue for what, rolling back the default installer? I agree that is a good stop-gap.

@fricklerhandwerk
Copy link
Contributor

No, for providing versioned installers.

We can always just roll back, but the interesting question is what to do next.

@corneliusroemer
Copy link

So have you already rolled back the default installer? This should be a few clicks and save lots of people quite some hassle. I don't know how many people install nix but it'll be dozens a day and they may well be lost by this.

@corneliusroemer
Copy link

Possibly related? #7992

@edolstra
Copy link
Member

edolstra commented Mar 7, 2023

We've reverted the installer to 2.13.3 for now.

@thufschmitt thufschmitt self-assigned this Mar 10, 2023
@Ericson2314
Copy link
Member Author

Ericson2314 commented Mar 10, 2023

Discussed in the Nix team Meeting:

  • @Ericson2314: users should be able to pick up system channels, while ~root is not accessible
  • @Theophane: global channels location is more public so we should be wary of using it, maybe keep /nix/var/nix/profile/per-user/root/channels?
  • @Ericson2314: Worried about having that path as a special case where the directories no longer "mean" what they did before
  • @thufschmitt: Could have a new path, and then the old path as a symlink to it
  • @Ericson2314: Sounds great!
  • Assigned to @thufschmitt

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-03-10-nix-team-meeting-minutes-39/26279/1

@Ericson2314
Copy link
Member Author

#8073 fixed this.

@Ericson2314
Copy link
Member Author

#8147 builds on this, but is just icing on the cake.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/sudo-nixos-rebuild-switch-upgrade-does-not-get-updates-anymore/27072/7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

6 participants