-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Dedup some derivation initialization logic, and test #14560
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
base: master
Are you sure you want to change the base?
Conversation
e8532fc to
d34ee4e
Compare
| * | ||
| * @param store The store to use for validation | ||
| */ | ||
| void checkInvariants(Store & store) const; |
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.
Why is this version needed now?
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.
It is used in parseJsonAndValidate, we validate the derivation before we compute its drvPath now. The drvPath was just used for error messages, but it we can write a better error message --- since we just computed the drv path, it won't mean anything to the human reading the error anyways where ("derivation from JSON" or similar will)
|
|
||
| # If we remove the input addressed to make it a deferred derivation, we | ||
| # still get the same result because Nix will see that need not be | ||
| # deferred and fill in the right input address for us. |
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.
Why is this a good thing? From reading checkInvariants, it looks like this is new behavior.
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.
checkInvariants doesn't do this, but fillInOutputPaths does. It is new behavior in the JSON code path, but not new behavior in the builtins.derivation code path.
src/libstore/derivations.cc
Outdated
| return; | ||
| } | ||
| auto & value = j->second; | ||
| if (value == "") { |
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.
Can this actually happen - I did not see it in the old code?
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.
The user-submitted JSON is arbitrary data, so yes it can happen. It also does happen in the builtins.derivationStrict code path already.
8149291 to
745c307
Compare
7f3f8f1 to
79cf901
Compare
These do a read/write test in the middles of some computation. They are an imperative way to test intermediate values rather than functionally testing end outputs.
`nix derivation add`, and its C API counterpart, now works a bit closer to `builtins.derivation` in that they don't require the user to fill-in input addressed paths correctly ahead of time. The logic for this is carefully deduplicated, between all 3 entry points, and also between the existing `checkInvariants` function. There are some more functional tests, and there are also many more unit tests. Co-authored-by: Sergei Zimmerman <[email protected]> Co-authored-by: edef <[email protected]>
9962fc3 to
620a694
Compare
Motivation
nix derivation add, and its C API counterpart, now works a bit closer tobuiltins.derivationin that they don't require the user to fill-in input addressed paths correctly ahead of time.The logic for this is carefully deduplicated, between all 3 entry points, and also between the existing
checkInvariantsfunction. There are some more functional tests, and there are also many more unit tests.Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.