-
Notifications
You must be signed in to change notification settings - Fork 8
libstore-c: add derivation functions #210
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
Changes from all commits
ea0c781
ff7618a
77dd7a0
ffe1d46
c1b766e
04dd0c7
b3184a6
d30a11c
3375bb0
6555f33
b2fff15
d7ce101
ad566a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -91,7 +91,7 @@ nix_store_get_version(nix_c_context * context, Store * store, nix_get_string_cal | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool nix_store_is_valid_path(nix_c_context * context, Store * store, StorePath * path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| bool nix_store_is_valid_path(nix_c_context * context, Store * store, const StorePath * path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -129,7 +129,7 @@ nix_err nix_store_realise( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Store * store, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StorePath * path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void * userdata, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void (*callback)(void * userdata, const char *, const char *)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void (*callback)(void * userdata, const char *, const StorePath *)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -144,8 +144,8 @@ nix_err nix_store_realise( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto & result : results) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto & [outputName, realisation] : result.builtOutputs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto op = store->ptr->printStorePath(realisation.outPath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(userdata, outputName.c_str(), op.c_str()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StorePath p{realisation.outPath}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(userdata, outputName.c_str(), &p); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -164,11 +164,74 @@ void nix_store_path_free(StorePath * sp) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete sp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void nix_derivation_free(nix_derivation * drv) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| delete drv; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StorePath * nix_store_path_clone(const StorePath * p) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new StorePath{p->path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_derivation * nix_derivation_clone(const nix_derivation * d) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new nix_derivation{d->drv, d->store}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto drv = nix::Derivation::fromJSON(*store->ptr, nlohmann::json::parse(json)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto drvPath = nix::writeDerivation(*store->ptr, drv, nix::NoRepair, /* read only */ true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| drv.checkInvariants(*store->ptr, drvPath); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new nix_derivation{drv, store}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS_NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_err nix_derivation_make_outputs( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_c_context * context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Store * store, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const char * json, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void (*callback)(void * userdata, const char * output_name, const char * path), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void * userdata) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto drv = nix::Derivation::fromJSON(*store->ptr, nlohmann::json::parse(json)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto hashesModulo = hashDerivationModulo(*store->ptr, drv, true); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (auto & output : drv.outputs) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix::Hash h = hashesModulo.hashes.at(output.first); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto outPath = store->ptr->makeOutputPath(output.first, h, drv.name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(userdata, output.first.c_str(), store->ptr->printStorePath(outPath).c_str()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto ret = nix::writeDerivation(*store->ptr, derivation->drv, nix::NoRepair); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return new StorePath{ret}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS_NULL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_err nix_store_copy_closure(nix_c_context * context, Store * srcStore, Store * dstStore, StorePath * path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -208,3 +271,109 @@ nix_err nix_store_get_fs_closure( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_err nix_store_drv_from_path( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_c_context * context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Store * store, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const StorePath * path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void (*callback)(void * userdata, const nix_derivation * drv), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void * userdata) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix::Derivation drv = store->ptr->derivationFromPath(path->path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const nix_derivation tmp{drv, store}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(userdata, &tmp); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_err nix_store_query_path_info( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_c_context * context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Store * store, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const StorePath * store_path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void * userdata, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_get_string_callback callback) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto info = store->ptr->queryPathInfo(store_path->path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto result = info->toJSON(store->ptr->config, true, nix::HashFormat::Nix32).dump(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(result.data(), result.size(), userdata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| std::vector<nix::DerivedPath> derived_paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (size_t i = 0; i < num_store_paths; i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const StorePath * store_path = store_paths[i]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| derived_paths.push_back(nix::SingleDerivedPath::Opaque{store_path->path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto results = store->ptr->buildPathsWithResults(derived_paths); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (auto & result : results) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nlohmann::json json; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix::to_json(json, result); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(userdata, result.path.to_string(store->ptr->config).c_str(), json.dump().c_str()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_err nix_derivation_get_outputs_and_optpaths( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_c_context * context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const nix_derivation * drv, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const Store * store, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void (*callback)(void * userdata, const char * name, const StorePath * path), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void * userdata) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto value = drv->drv.outputsAndOptPaths(store->ptr->config); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const auto & [name, result] : value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (auto store_path = result.second) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const StorePath tmp_path{*store_path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(userdata, name.c_str(), &tmp_path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(userdata, name.c_str(), nullptr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_err nix_derivation_to_json( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nix_c_context * context, const nix_derivation * drv, nix_get_string_callback callback, void * userdata) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (context) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->last_err_code = NIX_OK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| auto result = drv->drv.toJSON(drv->store->ptr->config).dump(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (callback) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| callback(result.data(), result.size(), userdata); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NIXC_CATCH_ERRS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
367
to
379
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick Fix parameter name to match header declaration. The parameter should be named nix_err nix_derivation_to_json(
nix_c_context * context,
const nix_derivation * drv,
const Store * store,
nix_get_string_callback callback,
- void * userdata)
+ void * user_data)
{
if (context)
context->last_err_code = NIX_OK;
try {
auto result = drv->drv.toJSON(store->ptr->config).dump();
if (callback) {
- callback(result.data(), result.size(), userdata);
+ callback(result.data(), result.size(), user_data);
}
}
NIXC_CATCH_ERRS
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Fix the inverted logic condition.
The condition logic appears to be inverted. When
testMainForBuidingPrereturns 0 (EXIT_SUCCESS), the test should continue rather than exit.Apply this fix:
📝 Committable suggestion
🤖 Prompt for AI Agents