libstore-c: add more derivation functions#14031
libstore-c: add more derivation functions#14031RossComputerGuy wants to merge 5 commits intoNixOS:masterfrom
Conversation
|
I have a preference that consumers should achieve these goals by deserializing the JSON themselves. Then we can make do with a smaller interface which will be easier to maintain and more stable. |
| NIXC_CATCH_ERRS | ||
| } | ||
|
|
||
| nix_err nix_derivation_get_outputs_and_optpaths( |
There was a problem hiding this comment.
This should just be the opt paths, which is useful for the FOD case. The outputs themselves can be gotten from the JSON.
There was a problem hiding this comment.
This is me elaborating what I wrote in #14031 (comment)
521f2c9 to
cd12d13
Compare
How do I get the JSON myself? All I have is a store path. |
|
|
Isn't there increased overhead if everything is being accessed through JSON? Wouldn't some operations make sense to do without deserializing? |
|
I would say optimization should come later. Let's see evidence of there being a bottleneck in practice before we make the interface bigger. |
df99081 to
d0c6698
Compare
d0c6698 to
4ffac98
Compare
|
c1e3593 to
bdf7104
Compare
|
Ah does anything use the |
|
I'm looking at our usage and it looks like there's not much usage of it. |
517c686 to
bec7506
Compare
bec7506 to
96b3f09
Compare
| nix_err nix_derivation_make_outputs( | ||
| nix_c_context * context, | ||
| Store * store, | ||
| const char * json, |
There was a problem hiding this comment.
this should take a nix_derivation, not parse the JSON itself.
There was a problem hiding this comment.
Then we'll have to remove the verify function to even be able to get a nix_derivation.
There was a problem hiding this comment.
hmm? I am not sure what you mean. You mean to make an input-addressed derivation?
There was a problem hiding this comment.
We'd have to remove this:
nix/src/libstore-c/nix_api_store.cc
Line 190 in 772a380
The checkInvariants function failing with a mismatch outpath hash error can prevent a nix_derivation from returning. If nix_derivation_make_outputs needs a nix_derivation and you can't get one without getting the right outpath hashes, now we have a catch-22 and it'll be impossible to add derivations.
There was a problem hiding this comment.
I am going to bed, but we can look into this soon, I think we should be able to untangle it perhaps simpler than you think
|
|
||
| /** | ||
| * @brief Gets the derivation as a JSON string | ||
| * |
There was a problem hiding this comment.
doc: Which CLI command is equivalent?
There was a problem hiding this comment.
I think it's similar to nix derivation show
| nix_c_context * context, | ||
| Store * store, | ||
| const char * json, | ||
| void (*callback)(void * userdata, const char * output_name, const char * path), |
There was a problem hiding this comment.
Probably a good idea to implement error handling here as well.
| void (*callback)(void * userdata, const char * output_name, const char * path), | |
| void (*callback)(nix_c_context * context, void * userdata, const char * output_name, const char * path), |
There was a problem hiding this comment.
I'm not sure how that helps
| * @brief Builds the paths, if they are a derivation then they get built. | ||
| * | ||
| * @note Path and result for the callback only exist for the lifetime of | ||
| * the call. Result is a string containing the build result in JSON. |
There was a problem hiding this comment.
doc: What kind of JSON? This should probably a link to the manual
There was a problem hiding this comment.
I don't think the JSON is documented.
| nix_err nix_store_build_paths( | ||
| nix_c_context * context, | ||
| Store * store, | ||
| const StorePath ** store_paths, | ||
| unsigned int num_store_paths, | ||
| void (*callback)(void * userdata, const char * path, const char * result), | ||
| void * userdata); |
There was a problem hiding this comment.
thought:
This mostly serves to support the use cases that are already well supported by nix-build/nix build.
This particular function would be subsumed by #14163. That may be ok, but if you want some of that functionality, you could pivot towards it and save the project the overhead of an extra "helper". Optional.
|
@RossComputerGuy is this PR still active given #14555 is merged? I'm interested in |
|
To deal with the conflicts and size, I've decided to close this PR so it can be sliced up. |
Motivation
Upstreaming more C API exposure, specifically more derivation related things.
Context
Comes from DeterminateSystems#210
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.