1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

libstore-c: add nix_store_get_fs_closure

This commit is contained in:
Tristan Ross 2025-09-19 09:48:08 -07:00
parent 07b96c1d14
commit 9abcc68ad1
No known key found for this signature in database
GPG key ID: 58BB826E9F8688F4
2 changed files with 54 additions and 0 deletions

View file

@ -126,6 +126,36 @@ StorePath * nix_store_parse_path(nix_c_context * context, Store * store, const c
NIXC_CATCH_ERRS_NULL
}
nix_err nix_store_get_fs_closure(
nix_c_context * context,
Store * store,
const StorePath * store_path,
bool flip_direction,
bool include_outputs,
bool include_derivers,
void * userdata,
void (*callback)(nix_c_context * context, void * userdata, const StorePath * store_path))
{
if (context)
context->last_err_code = NIX_OK;
try {
const auto nixStore = store->ptr;
nix::StorePathSet set;
nixStore->computeFSClosure(store_path->path, set, flip_direction, include_outputs, include_derivers);
if (callback) {
for (const auto & path : set) {
const StorePath tmp{path};
callback(context, userdata, &tmp);
if (context && context->last_err_code != NIX_OK)
return context->last_err_code;
}
}
}
NIXC_CATCH_ERRS
}
nix_err nix_store_realise(
nix_c_context * context,
Store * store,

View file

@ -245,6 +245,30 @@ void nix_derivation_free(nix_derivation * drv);
*/
nix_err nix_store_copy_closure(nix_c_context * context, Store * srcStore, Store * dstStore, StorePath * path);
/**
* @brief Gets the closure of a specific store path
*
* @note The callback borrows each StorePath only for the duration of the call.
*
* @param[out] context Optional, stores error information
* @param[in] store nix store reference
* @param[in] store_path The path to compute from
* @param[in] flip_direction
* @param[in] include_outputs
* @param[in] include_derivers
* @param[in] callback The function to call for every store path, in no particular order
* @param[in] userdata The userdata to pass to the callback
*/
nix_err nix_store_get_fs_closure(
nix_c_context * context,
Store * store,
const StorePath * store_path,
bool flip_direction,
bool include_outputs,
bool include_derivers,
void * userdata,
void (*callback)(nix_c_context * context, void * userdata, const StorePath * store_path));
// cffi end
#ifdef __cplusplus
}