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

Building an ISO from a flake doesn't ensure that experimental-feature flakes is enabled, so <nixpkgs> does not evaluate #292465

Open
lf- opened this issue Feb 29, 2024 · 4 comments
Assignees
Labels
0.kind: bug Something is broken

Comments

@lf-
Copy link
Member

lf- commented Feb 29, 2024

Describe the bug

ping @tpwrules

Regression (well, kinda) from #254405

Report: https://matrix.to/#/!VRULIdgoKmKPzJZzjj:nixos.org/$2BjkrwyIQLbywLKdVlza-qCtD-2VqEn8LyDrhrYlieg?via=nixos.org&via=matrix.org&via=nixos.dev

To our understanding, the issue is that nixos-install runs nix-build <nixpkgs> -A hello or a similar command, which fails if flakes are disabled but NIX_PATH contains a flake reference. This is, on the first order, reasonable behaviour from nix, but it does mean that our stuff is broken in such an instance.

The fix here is probably to simply enable flakes on the resulting system by default so that flake:nixpkgs in NIX_PATH will evaluate correctly. I don't think this is a major problem to do, since by having encountered this problem in the first place, our user has already been using flakes!

Another secondary bug is that the channel is copied twice to ISOs: possibly we should either disable the channel for ISOs generated with the flake pins, or we should disable the flake pins on ISOs.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Build ISO or system with nixos-unstable without enabling the flakes experimental feature
  2. nixos-install fails with weird error

Expected behavior

A clear and concise description of what you expected to happen.
Expect it to either work using the channel in the ISO or using the pinned nixpkgs.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
output here

Add a 👍 reaction to issues you find important.

@lf- lf- added the 0.kind: bug Something is broken label Feb 29, 2024
@lf- lf- self-assigned this Feb 29, 2024
@tpwrules
Copy link
Contributor

tpwrules commented Mar 4, 2024

Thank you!

I don't think this is a major problem to do, since by having encountered this problem in the first place, our user has already been using flakes!

This does not necessarily follow, I build my installers inside a flake but they get distributed to users who don't have any opinion on the concept. I don't think it's a big deal but is worth noting.

Another secondary bug is that the channel is copied twice to ISOs: possibly we should either disable the channel for ISOs generated with the flake pins, or we should disable the flake pins on ISOs.

I see this as a big problem considering I am trying to build minimal ISOs and we are trying to conserve cache space. I think disabling the flake pin makes more sense, or figure out how to redirect it to the channel?

@lf-
Copy link
Member Author

lf- commented Mar 4, 2024

It won't affect Hydra because it's not using the flake as far as I know. But we should fix it. I don't think you can redirect the flake ref to a channel very nicely due to it being in a subdirectory, so I think the most expedient move is to just mkdefault the nixpkgs.flake options to false in the installer.

@tpwrules
Copy link
Contributor

tpwrules commented Mar 5, 2024

Hm, it seems strange that they cannot share the store path. Do you know off the top of your head how the channel gets set up in the installers?

I usually use this which I suppose sets up the registry then links the same thing to /etc/nix/inputs. The new way is the flake:nixpkgs element in NIX_PATH? I'm not very familiar with the registry yet to be honest.

@lf-
Copy link
Member Author

lf- commented Mar 5, 2024

Hm, it seems strange that they cannot share the store path. Do you know off the top of your head how the channel gets set up in the installers?

this or so aiui: https://github.com/nixos/nixpkgs/blob/94b810348a5aa74be5cdc3a1fa6787e8abbc5704/nixos/modules/installer/cd-dvd/channel.nix

I usually use this which I suppose sets up the registry then links the same thing to /etc/nix/inputs. The new way is the flake:nixpkgs element in NIX_PATH? I'm not very familiar with the registry yet to be honest.

the registry way/non registry way both have the same issue, it is because the channel has a different name and then inside the channel there is a nixpkgs dir iirc; there is also metadata in the channel.

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
Projects
None yet
Development

No branches or pull requests

2 participants