-
-
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
More intelligent subflake locking. #6352
Comments
That’s indeed really annoying. I don’t think using the parent’s lock would be a good idea (if only because it’s too much of an overapproximation), but maybe we could be able to specify that some inputs should be systematically refreshed when running a {
inputs.child.url = "path:./child";
inputs.child.autoUpdate = true;
} and any |
Some prior discussion (though tracking this in an open issue is probably a good idea): #3978 (comment) |
This makes sense except for the case of |
It feels like you're misunderstanding here. There are 2 meanings of 'lock' at play. In all cases, the subflake's lock file should be used. The question is whether the hash of the subflake gets recorded in the lockfile of the consuming flake, when the consuming flake is actually stored in the same git commit. In the case you brought up, there is no consuming flake, and thus the kind of locking in question isn't even happening. |
Gotcha. Well as someone who's been bitten badly by subflake locking I definitely agree with "make relative subflakes work more better". Relocking every directory in my tree before committing is obnoxious, and honestly I only remember to do it post-hoc when I get a crash later on another box. The project that I fully can't get them to work with uses "merge and squash" PR as the only option, so relative paths will always blow up unless there's something I misunderstood about how to manage the locks. From what I can tell the changes to the commit hash made by the squash cause a hash mismatch that isn't recognized as "dirty", but also fails to match the locked hash. If you Honestly what I want is "experimental commands in every directory", with a repo global lockfile. |
Relative 'path:' flake inputs now use the containing flake's InputAccessor. This has the following implications: * They're no longer locked in the lock file. * They don't cause an additional copy to the store. * They can reference the containing directory (i.e. a subflake can have an input '../foo', so long as it doesn't go outside the top-level containing flake). Note: this is not a complete fix for subflake handling, since the lock file currently makes it ambiguous what the containing flake is. We'll probably need to add another field to the lock file for that. Fixes NixOS#6352.
#6530 improves subflake locking, but is currently blocked on evaluation regressions. We've made some progress merging some stable parts of that PR, so perhaps its solution for subflakes could be extracted and merged independently too?
|
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
Are subflakes as described in the original post workable at all under today's Nix? I tried to adopt that exact structure and it all worked great locally, but then on Hydra building from gitlab URL it hit evaluation errors (with Nix 2.13.3):
This seems to be a complete showstopper as far as being able to use multiple flakes in the same repo for anything other than local development. EDIT: Looks like the master issue for this is #3978. |
the best
I'm aware of this issue. Though I'm not clear on the best path to fix it. @roberth has had proposed some lockfile changes that can help fix. |
This is not a fix, but rather a workaround. For instance, it can't work with I think @edolstra has written an experimental fix, but he hasn't opened a viable PR for it yet. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/my-nix-subflake-does-not-resolve-nixpkgs/55941/4 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/my-nix-subflake-does-not-resolve-nixpkgs/55941/8 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/my-nix-subflake-does-not-resolve-nixpkgs/55941/1 |
What's the status on this? |
Nix 2.26 includes I don't see anything in this thread that isn't covered by that (despite plenty of room for scope creep 😄) So I think this one can be closed. |
My use case is met with the changes made in #10089. I had a generated flake that included a small metadata component that I wanted to be able to later use overrides against in order to do hash comparisons. So like, generated timestamp flake X and generated timestamp flake Y (from say, an hour later) would trivially compare as unique if the timestamp itself is part of the content, but by putting it in a subflake, I can override one to the other when comparing, and that tells me if the content itself has changed (and therefore if the new timestamp flake should be committed and shipped). |
Is your feature request related to a problem? Please describe.
flake.nix
:child/flake.nix
:Describe the solution you'd like
Nix should recognize that the subflake is already locked by the parent flake's rev, and thus doesn't need its hash put into
flake.lock
at all, removing any possibility of a parent and child from different commits interacting. Ideally the dirty tree case should work too.Describe alternatives you've considered
Nix could try to keep the hash in
flake.lock
up to date somehow, but it fundamentally doesn't have a hook into the proper time to do that, sincegit commit
doesn't call nix.The parent flake could invoke the child by
builtins.getFlake
, rather than as an input, but currently all methods of doing that suffer from similar problems, and you wouldn't have access to input overriding functionality.The text was updated successfully, but these errors were encountered: