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
flake check: allow modules to be paths #7356
Conversation
src/nix/flake.cc
Outdated
if (v.type() == nPath) { | ||
PathSet context; | ||
auto path = state->coerceToPath(pos, v, context); | ||
state->evalFile(path, v); |
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.
Since v
is a reference pointing into the flake, evalFile
will mutate the flake attribute.
That could lead to surprising behavior down the road.
You could copy v
into a temporary Value
after forcing v
and work with that instead of v
.
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.
Made a pointer to avoid copying.
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.
Actually that was silly, copying Value
s is cheap.
cbe49c8
to
bb17a63
Compare
bb17a63
to
b873db0
Compare
Not in favor of this. In general we should avoid magic overloads. Imagine if Nix had a type system - what would the type of Also, this seems to be entirely to work around a deficiency in the NixOS module system (namely that it uses file names as keys). It would be better to fix this in the module system. |
Following this line of reasoning, Nix should be a compiled language, because otherwise, it'd have to use runtime type tags.
The module system has good reason not to hide path imports from its implementation. Removing path imports from the module system would break everything and cause a huge regression in error message quality. So how? I've maintained the module system for three years. I've dealt with this very part of the system. What you're suggesting is wishful thinking. I'll be happy to see a replacement for the module system that's actually better, but that is not a project we can start before making Flakes release-worthy. You can't change the module system by disallowing this, so please don't. You're only making the Flakes user experience worse. NixOS has been a construct that exists entirely within the language, and that Nix did not have to be aware of. Arguably, |
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.
nix flake check
does not work in nixpkgs without this
what @roberth said is true
Discussed in Nix team meeting 2022-12-09: Agreement: Maintaining knowledge about NixOS modules is a layer violation. This is outside of Nix's responsibility. Decision: Close the pull request. Complete discussion
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2022-12-09-nix-team-meeting-minutes-15/23951/1 |
The proposed alternative is to remove this check altogether. |
Fixes #6866