Skip to content

Commit

Permalink
Merge pull request #11356 from ehmry/nix_store_copy_closure
Browse files Browse the repository at this point in the history
Add nix_store_copy_closure to libstore-c
  • Loading branch information
roberth authored Aug 23, 2024
2 parents 0bcc83d + 5d28a00 commit 85f1aa6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libstore-c/nix_api_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,15 @@ StorePath * nix_store_path_clone(const StorePath * p)
{
return new StorePath{p->path};
}

nix_err nix_store_copy_closure(nix_c_context * context, Store * srcStore, Store * dstStore, StorePath * path)
{
if (context)
context->last_err_code = NIX_OK;
try {
nix::RealisedPath::Set paths;
paths.insert(path->path);
nix::copyClosure(*srcStore->ptr, *dstStore->ptr, paths);
}
NIXC_CATCH_ERRS
}
10 changes: 10 additions & 0 deletions src/libstore-c/nix_api_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ nix_err nix_store_realise(
nix_err
nix_store_get_version(nix_c_context * context, Store * store, nix_get_string_callback callback, void * user_data);

/**
* @brief Copy the closure of `path` from `srcStore` to `dstStore`.
*
* @param[out] context Optional, stores error information
* @param[in] srcStore nix source store reference
* @param[in] srcStore nix destination store reference
* @param[in] path Path to copy
*/
nix_err nix_store_copy_closure(nix_c_context * context, Store * srcStore, Store * dstStore, StorePath * path);

// cffi end
#ifdef __cplusplus
}
Expand Down

0 comments on commit 85f1aa6

Please sign in to comment.