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

Nix installable resolution is actually impure for supposedly pure attributes like nixosConfigurations #8665

Closed
roberth opened this issue Jul 8, 2023 · 4 comments · Fixed by #8852
Labels
feature Feature request or proposal flakes idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. new-cli Relating to the "nix" command

Comments

@roberth
Copy link
Member

roberth commented Jul 8, 2023

Describe the bug

Let me be clear. We usually don't want to ignore the context of a Nix CLI invocation. nix run should not require users to specify their platform.

However, in some cases we do want to ignore the CLI context. For instance, nixosConfigurations is not behind a system attribute set, because a machine configuration should be built in one way only. Reproducibly.

It would seem that the documented schema enforces this. No system attribute means one way to do it, but this is actually not the case, and users are finding out. I'll try not to proliferate the bad idea, but it involves installable resolution. So I'll jump to the solution instead.

Steps To Reproduce

Intentionally omitted.

Expected behavior

Nix implements a flag so that currentSystem is not used during installable resolution. I believe this comes down to treating the fragment as a literal attribute path without any lookup trickery.
nixos-rebuild passes this flag.

nix-env --version output

Additional context

Even nixpkgs.buildPlatform would be a massive impurity not to be overlooked by a flake's git history.

Priorities

Add 👍 to issues you find important.

@roberth roberth added bug new-cli Relating to the "nix" command flakes labels Jul 8, 2023
@roberth roberth added this to Nix team Jul 8, 2023
@edolstra edolstra added feature Feature request or proposal idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. and removed bug labels Jul 14, 2023
@edolstra edolstra removed this from Nix team Jul 14, 2023
@nixos-discourse
Copy link

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

https://discourse.nixos.org/t/2023-07-14-nix-team-meeting-minutes-71/30472/1

@gytis-ivaskevicius
Copy link
Contributor

If the proposal is to change nixosConfigurations schema (like doing nixosConfigurations.<system>.<hostname>) then I'd appreciate it if this was to be implemented as well #6257

@blaggacao
Copy link
Contributor

More Context on home-manager

Home Manager users are fundamentally system-portable. Advancement here could trigger evolution there.

@roberth
Copy link
Member Author

roberth commented Jul 16, 2023

This doesn't change the schema. The schema can be discussed at #6257.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal flakes idea approved The given proposal has been discussed and approved by the Nix team. An implementation is welcome. new-cli Relating to the "nix" command
Projects
None yet
5 participants