-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support self-fetching parameters in flake.nix #5312
Comments
There is a very good reason why |
There is no possible mechanism to read the flake inputs before |
@nrdxp — I’ve been thinking about this a bit because it’s going to bite everyone who tries to flakeify upstream projects that use submodules, like, in my case, qemu. So far the best idea I’ve come up with is to write the flake to use an auxiliary input, in addition to Unfortunately, that still leaves several quality-of-life problems that I wonder if we can fix: a) that the self input is fetched but is unused (other than for obtaining flake.nix/flake.lock) b) that the self-with-submodules input is “locked” when we’d rather that it be “derived from” or “tied” to self — e.g. so that we see dirty working copy edits / whatever the flake-ref resolves to when being built, and don’t have to remember to push commits that bump flake.lock just to test changes. (P.S. — if you’re interested in this approach, I wrote more at https://gist.github.com/mstone/4218e6fa9ef98e5153f543fb8e7b4743 with several variations in this idea, though I’m not really sure that any of them are ready for prime time. :-/) |
Would this still be the case with #3121? Afaiu, in that case we would evaluate |
#3121 only addresses the case of a local git tree. The fundamental issue is that we do a |
Am I missing something? Or why can't the answer just be as simple as manipulate self with command line args? So have a |
Command line args would work in theory, but if I'm conceptualizing it correctly, it would also break purity since the end result would be vastily different depending on the args passed. |
While I like them for other reasons, I disagree that CLI improvements are sufficient here: — instead, I think the point here is that flake-authors need a way to specify all build instructions, including what code to build, as part of the flake definition — that way, end-users get something that “just works” without more detailed communication from the flake authors (e.g. of a special URL to build, or extra CLI arguments, etc.) whenever possible. |
I think that it's inevitable that flake authors need to communicate with flake users. As for purity or consistency, I don't see many scenarios in which someone would have a requirement for a flake and the flake would still build without it. A build that is missing files will pretty much always fail to build. If your building a top level flake you should be checking the docs released by the author and use the proper args. |
IIRC, more general flake arguments passed from the cli to the flake builder were considered early on, similar to how one can pass arguments to nix expressions with the old |
In principle you should be able to use a flake URL like Also this wouldn't be very user-friendly |
@edolstra, @nrdxp, @kero0 -- given the discussion above, I'd like to try to summarize what I think we've collectively concluded so far. Please let me know if you think I've missed anything critical or if you think I've misstated/mischaracterized any of the following facts:
Additionally, I think we seem to be orbiting the following "nascent UX principles" (though with some conflicting opinions about the latter two):
Finally, I think we are juggling the following emergent design constraints / conclusions:
Have I got anything wrong here? Thanks! -- Michael |
for 11, couldn't we avoid a double fetch by generating lock entries for submodules? |
@nrdxp -- oooh, interesting, I'll need to think about that. I wonder if that might also make it possible to handle |
My suggestion for how to fix this: Flakes could have a {
metadata.fetch-git-submodules = true;
} The metadata attributes would also have to be in normal-form, and would not allow any path literals. This means that Nix can fetch the flake, check the metadata, then check whether to also fetch the submodules before evaluating any Nix code. With this you don't have the double-fetching problem, but it's restricted to Git. This isn't "clean" IMO, but IMHO the problem is Git itself not always fetching submodules. Git should have from the beginning enforced fetching submodules, and we have to work around that now. The only downside with always fetching submodules in Nix is that it breaks backward compatibility in some subtle ways, and doesn't work well with git-crypt. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/is-it-possible-to-make-a-flake-that-has-no-source-tree/16037/3 |
`self` flake can't have submodules. see: NixOS/nix#5312 NixOS/nix#4435 for now, it seems cleaner to just work through `Cargo.toml`, with specified git revisions...
Currently, I use What if we added a nix configuration option, e.g. Also, since flakes have a |
This sounds like the cleanest solution to me, assuming we can get approval for the new nix.conf setting. |
We have multiple solutions to prevent double fetching. Caching:
Fetcher dependent solutions:
The caching solutions introduce significant complexity. This may be worth embracing at some point, but until then, the fetcher dependent solutions don't impose complexity on the rest of the system, making them feasible to implement first, to solve 90% of the problem. I'll rename this issue, as the current problem is only about fetch parameters. The remainder of original problem statement is to treat similar things similarly, and I think we can agree on that. If there's another issue related to |
This comment was marked as resolved.
This comment was marked as resolved.
self
input
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
#5284 happened, so instead I'll open a proper issue to address what I feel would be the "correct" solution since I am incapable of implementing it atm.
I see no particular reason why
self
should be especially handicapped from the other inputs, but should be able to be easily handled as a regulargit
type input, or whichever active VCS Nix can detect.you wouldn't even have to change the syntax, but simply allow
inputs.self.submodules = true
, for example.Nix would simply have to know that
inputs.self
is the currentself
.The text was updated successfully, but these errors were encountered: