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

Installer doesn't update nixpkgs flake input correctly #204292

Open
roberth opened this issue Dec 3, 2022 · 6 comments
Open

Installer doesn't update nixpkgs flake input correctly #204292

roberth opened this issue Dec 3, 2022 · 6 comments
Labels
0.kind: bug Something is broken 6.topic: flakes The experimental Nix feature 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: user experience

Comments

@roberth
Copy link
Member

roberth commented Dec 3, 2022

Describe the bug

Weird input resolution behavior that's uncharacteristic for a distro that emphasizes being reproducible and boring.

Steps To Reproduce

Steps to reproduce the behavior:

  1. install nixos 22.11 with the minimal installer
  2. nix flake init in /etc/nixos
  3. add nixosConfigurations."nixos" = nixpkgs.lib.nixosSystem { modules = [ ./configuration.nix ]; }
  4. boot into installation
  5. nixos-rebuild switch
  6. we're now running nixos 23.05 (unstable). Ok?
  7. be unhappy about the partition layout and learn that a graphics driver fix landed in the release
  8. boot into installer to perform an offline fs shrinking and partition table configuration update
  9. nix flake lock --update-input nixpkgs to update the graphics driver
  10. boot into installation
  11. graphics driver is still the old version
  12. install Pop! OS

Expected behavior

At (6), do not upgrade to nixos-unstable.

At (9), do not downgrade to the installer nixpkgs

Suggested solution

Remove the flake registry from NixOS to solve (9)

Remove the flake registry from Nix, so that the user must specify the channel, solving (6) and (9).

Screenshots

Additional context

Notify maintainers

Metadata

NixOS 22.11 minimal ISO
Nix 2.11.0
Nix 2.11.1

@roberth roberth added 0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: user experience 6.topic: flakes The experimental Nix feature labels Dec 3, 2022
@NickCao
Copy link
Member

NickCao commented Dec 3, 2022

I vote for removing the flake registry, it's an obscure (not properly documented/advertised) feature that users have little control over. Its interface is far less intuitive and discoverable compared to nix-channel.

@SuperSandro2000
Copy link
Member

SuperSandro2000 commented Dec 7, 2022

I vote for removing the flake registry

That wouldn't work and we must keep some variant of it because otherwise nix shell nixpkgs#hello breaks and typing github:nixos/nixpkgs everytime instead is even more inconvenient. Ideally I would want to type nix shell hello.

Its interface is far less intuitive and discoverable compared to nix-channel.

I strongly disagree with this. I have seen many people that struggle with managing channels and especially the root fallback channel and often forgetting that it exists and needs to be updated.


The underlying issue here is that the flake template defaults to nixpkgs and not nixos-unstable or nixos-stable. Also the template fails to explain that with a comment. Generally the template is very bare and almost the bare minimum you need to work and it should be improved a lot.
Completely removing the flake registry would definitely be the wrong decision here.

@NickCao
Copy link
Member

NickCao commented Dec 7, 2022

I agree that the use of nix shell nixpkgs#hello should be kept possible, but it should be carefully treated so that users get packages from the exact commit their system is on, a possible choice would be setting nix.registry.nixpkgs.flake = inputs.nixpkgs in the generated NixOS configuration. And the flake inputs should be explicitly specified in the template, not implicitly from a flake registry fetched from a github url shared by the entire world.

TLDR: it should be the system flake controlling the content of the system wide flake registry, not the other way around.

@roberth
Copy link
Member Author

roberth commented Dec 7, 2022

Let's defer a removal from Nix to NixOS/nix#7422

We can discuss how Nixpkgs/NixOS do / do not use the registry here.

I vote for removing the flake registry

That wouldn't work

Let's continue this in the nix issue, where I've watered it down to removing the system registry.

Its interface is far less intuitive and discoverable compared to nix-channel.

I strongly disagree with this.

Clearly the system registry and nix-channel were cut from the same cloth. Which one is worse is subjective, but they're both bad.

The underlying issue here is that the flake template defaults to nixpkgs and not nixos-unstable or nixos-stable.

This wouldn't solve the issue that the installer's system flake registry tries to solve. If the installer doesn't specify anything in its flake registry, the installer and nix flake lock / update would behave predictably.

At that point, what would be the purpose of even having a registry entry?

TLDR: it should be the system flake controlling the content of the system wide flake registry, not the other way around.

It would still be an implicit magical override that makes the nixpkgs flakeref behave unpredictably.

And the flake inputs should be explicitly specified in the template,

I agree, but this again makes the flake registry useless, and it doesn't force "correct" use.

@SuperSandro2000
Copy link
Member

I agree that the use of nix shell nixpkgs#hello should be kept possible, but it should be carefully treated so that users get packages from the exact commit their system is on, a possible choice would be setting nix.registry.nixpkgs.flake = inputs.nixpkgs in the generated NixOS configuration.

Then it would work different between nixos and none nixos systems which is also not great.

And the flake inputs should be explicitly specified in the template, not implicitly from a flake registry fetched from a github url shared by the entire world.

One improvement I would do.

@sg-qwt
Copy link
Contributor

sg-qwt commented Mar 4, 2023

I cannot comment on none nixos setup, but can we make nix.registry.nixpkgs.flake = inputs.nixpkgs default on flaked based nixos system? That'd almost be the expected behavior of people want. I've seen so many people confuesd why nix shell nixpkgs#hello gets a different version then their system flake and then ended up adding nix.registry.nixpkgs.flake = inputs.nixpkgs manually by themselves.

omi-coide added a commit to omi-coide/nixos-config that referenced this issue Mar 4, 2023
omi-coide added a commit to omi-coide/nixos-config that referenced this issue Mar 4, 2023
omi-coide added a commit to omi-coide/nixos-config that referenced this issue Mar 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: flakes The experimental Nix feature 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: user experience
Projects
None yet
Development

No branches or pull requests

4 participants