-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Hash always has a valid type #3738
Conversation
… into hash-always-has-type
@@ -115,7 +115,8 @@ struct ValidPathInfo | |||
{ | |||
StorePath path; | |||
std::optional<StorePath> deriver; | |||
Hash narHash; | |||
// TODO document this | |||
std::optional<Hash> narHash; |
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.
Here is one of the now-optional hashes
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.
@edolstra So I checked and while this one is optional, the constructor for NarInfo (derived class) requires that it is present with assertions. Is that good enough for now, or do you also want the refactor so that it is required everywhere? (I do recall you were saying the nix installer trick where the nar hash would be missing is long gone.)
(I must admit due to #3640 I am a bit partial to keeping it optional, but I'm happy to do whatever you like.)
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.
I think this one should not be optional since a store path should always have a NAR hash.
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.
This is actually turns out to be a fairly substantial change, because it looks like the BinaryCacheStore::addToStore
overload that doesn't take the ValidPathInfo
was uploading flat files as-is and calling them nars, with the narHash
unset.
I think that a bug not intended feature, but either way, fixing it is the sort of major behavior change I rather do separately from this refactor which has no behavior changes?
src/libfetchers/tree-info.hh
Outdated
@@ -11,7 +11,7 @@ namespace nix::fetchers { | |||
|
|||
struct TreeInfo | |||
{ | |||
Hash narHash; | |||
std::optional<Hash> narHash; |
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.
Another
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.
Though I think this one is fine and just means the hash is calculted---obviously these builtins aren't going to be making non-CA paths.
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.
I think this one should not be optional. Anyway it's better to leave libfetchers unchanged since it's all rewritten in the flakes branch.
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.
We thought it might be easy to fix this, but it isn't either: the caching stuff doesn't store the narHash
and since the cache also doesn't distinguish between stores, doing a queryPathInfo
to get the Nar hash in the case of a cache-hit doesn't work reliably enough to pass the test suite.
Perhaps something could be made to work, but like you said libfetchers
is all rewritten anyways, and I think the 2 lines we changed in libfetchers
with the std::optional
is much more minimal than whatever it would take to make it work without the std::optional
.
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.
This change did go away with the flakes branch being merged, yay!
@@ -10,7 +10,7 @@ struct NarInfo : ValidPathInfo | |||
{ | |||
std::string url; | |||
std::string compression; | |||
Hash fileHash; | |||
std::optional<Hash> fileHash; |
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.
another
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.
Per meeting this one is OK
The aim of this check was just to ensure each key occurs once.
058a156
to
1be279a
Compare
afe35d6
to
dbffd30
Compare
There are some conflicts, could you have a look at those? Otherwise LGTM. |
OK, fixed! Will get the PRs that include this too. |
Again?! :D |
Fixed. Guess I shouldn't complain as it's my own other PR which caused the conflict :) |
This PR introduced a evaluation error for me when building the
The same build was successful with a5f7d31 (one commit before): nix run 'nix/a5f7d310dd10fe86b6f6aa1c2771c30f113741d4' -- build -f https://github.com/nmattia/niv/archive/c0a61e6283933fa6eed6d3451ffd86c9df5209ec.tar.gz -v --show-trace Not sure if |
Thanks for reporting this, I do think it's a bug on the Nix side I'm sorry to have introduced. #3845 is the next step of this process, and I think will root out any renaming bugs, but if that can't be done fast enough we can separately investigate this one |
The build failure is fixed in #3881. Thanks for your effort. |
Actually was totally coincidental! (As far as I know.) Thanks, Matt! |
@edolstra based on your passing remark on our call, we made some of the ValidPathInfo/NarInfo hashes
std::optional
, but we're not really sure what the correct "bussiness logic" is, so that will be important to review.These two remaining test failures may also turn up interesting things.edit nope, they weren't.The parser changes use some of the same techniques I used in #3730 -- lots of
std::string_view
including arest
I mutate as I go----in general trying to write the code as if I had proper parser combinators at my disposal.The rest is rote.