1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-29 05:31:00 +01:00

Add new C API for working with derivations

Also test the APIs we just added.
This commit is contained in:
John Ericson 2025-09-02 11:20:51 -04:00
parent 1a69fc6ab5
commit 9bc218ca3f
13 changed files with 270 additions and 47 deletions

View file

@ -23,6 +23,8 @@ extern "C" {
typedef struct Store Store;
/** @brief Nix store path */
typedef struct StorePath StorePath;
/** @brief Nix Derivation */
typedef struct nix_derivation nix_derivation;
/**
* @brief Initializes the Nix store library
@ -207,6 +209,32 @@ 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 Create a `nix_derivation` from a JSON representation of that derivation.
*
* @param[out] context Optional, stores error information.
* @param[in] store nix store reference.
* @param[in] json JSON of the derivation as a string.
*/
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json);
/**
* @brief Add the given `nix_derivation` to the given store
*
* @param[out] context Optional, stores error information.
* @param[in] store nix store reference. The derivation will be inserted here.
* @param[in] derivation nix_derivation to insert into the given store.
*/
StorePath * nix_add_derivation(nix_c_context * context, Store * store, nix_derivation * derivation);
/**
* @brief Deallocate a `nix_derivation`
*
* Does not fail.
* @param[in] drv the derivation to free
*/
void nix_derivation_free(nix_derivation * drv);
/**
* @brief Copy the closure of `path` from `srcStore` to `dstStore`.
*