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
Input::fetchToStore(): Don't try to substitute #10612
base: master
Are you sure you want to change the base?
Conversation
Having a narHash doesn't mean that we have the other attributes returned by the fetcher (such as lastModified or rev). For instance, $ nix flake metadata github:NixOS/patchelf/7c2f768bf9601268a4e71c2ebe91e2011918a70f Last modified: 2024-01-15 10:51:22 but $ nix flake metadata github:NixOS/patchelf/7c2f768bf9601268a4e71c2ebe91e2011918a70f?narHash=sha256-PPXqKY2hJng4DBVE0I4xshv/vGLUskL7jl53roB8UdU%3D (does not print a "Last modified") The latter only happens if the store path already exists or is substitutable, which made this impure behaviour unpredictable. Fixes NixOS#10601.
a1920a0
to
ff107d9
Compare
(thoughts) I'd still be concerned about similar bugs, because the code isn't structured in a way that would make such a bug somewhat harder to write.
This crucial property is hard to test, so we should try to structure the code in a way that makes this property easy to determine (I won't say prove; too absolute to be realistic). In my previous attempt to improve this, I focused on giving types to the input side, which wasn't all that fruitful, given the amount of change and effort required. Maybe it'd be more effective to put the output into a struct before returning it as attributes? |
Is it necessary not to substitute? What if the the missing fields can be obtained from the lock file instead? |
Substitution could still be done for locked flake inputs, because there we know that we have all the attributes. We do have the |
Aren't those saved to the lock then? |
They are, this problem only occurs on the CLI if you pass |
I guess part of the issue is the removal of Regardless, correctness is more important than performance, and the substitution shortcut makes it harder to reason about the correctness of fetchers, so it's probably best to get rid of it for now. |
Fair enough. Some optimizations can be done later, unless we move towards a non-optimizable design. I don't think that's the case here. EDIT: Some optimizations |
Motivation
Having a
narHash
doesn't mean that we have the other attributes returned by the fetcher (such aslastModified
orrev
). For instance,but
The latter only happens if the store path already exists or is substitutable, which made this impure behaviour unpredictable.
Fixes #10601. Note: lazy-trees already had this fix, because it no longer requires all locked nodes to have a
narHash
.Context
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.