|
Nix 2.31.4
Nix, the purely functional package manager: C API (experimental)
|
C bindings for nix libstore. More...
Files | |
| file | nix_api_store.h |
| Main entry for the libstore C bindings. | |
Typedefs | |
| typedef struct Store | Store |
| Reference to a Nix store. | |
| typedef struct StorePath | StorePath |
| Nix store path. | |
Functions | |
| nix_err | nix_libstore_init (nix_c_context *context) |
| Initializes the Nix store library. | |
| nix_err | nix_libstore_init_no_load_config (nix_c_context *context) |
| Like nix_libstore_init, but does not load the Nix configuration. | |
| Store * | nix_store_open (nix_c_context *context, const char *uri, const char ***params) |
| Open a nix store. | |
| void | nix_store_free (Store *store) |
| Deallocate a nix store and free any resources if not also held by other Store instances. | |
| nix_err | nix_store_get_uri (nix_c_context *context, Store *store, nix_get_string_callback callback, void *user_data) |
| get the URI of a nix store | |
| nix_err | nix_store_get_storedir (nix_c_context *context, Store *store, nix_get_string_callback callback, void *user_data) |
| get the storeDir of a Nix store, typically "/nix/store" | |
| StorePath * | nix_store_parse_path (nix_c_context *context, Store *store, const char *path) |
| Parse a Nix store path into a StorePath. | |
| void | nix_store_path_name (const StorePath *store_path, nix_get_string_callback callback, void *user_data) |
| Get the path name (e.g. "name" in /nix/store/...-name) | |
| StorePath * | nix_store_path_clone (const StorePath *p) |
| Copy a StorePath. | |
| void | nix_store_path_free (StorePath *p) |
| Deallocate a StorePath. | |
| bool | nix_store_is_valid_path (nix_c_context *context, Store *store, StorePath *path) |
| Check if a StorePath is valid (i.e. that corresponding store object and its closure of references exists in the store) | |
| nix_err | nix_store_real_path (nix_c_context *context, Store *store, StorePath *path, nix_get_string_callback callback, void *user_data) |
| Get the physical location of a store path. | |
| nix_err | nix_store_realise (nix_c_context *context, Store *store, StorePath *path, void *userdata, void(*callback)(void *userdata, const char *outname, const char *out)) |
| Realise a Nix store path. | |
| nix_err | nix_store_get_version (nix_c_context *context, Store *store, nix_get_string_callback callback, void *user_data) |
| get the version of a nix store. | |
| nix_err | nix_store_copy_closure (nix_c_context *context, Store *srcStore, Store *dstStore, StorePath *path) |
| Copy the closure of path from srcStore to dstStore. | |
C bindings for nix libstore.
libstore is used for talking to a Nix store
| nix_err nix_libstore_init | ( | nix_c_context * | context | ) |
Initializes the Nix store library.
This function should be called before creating a Store This function can be called multiple times.
| [out] | context | Optional, stores error information |
| nix_err nix_libstore_init_no_load_config | ( | nix_c_context * | context | ) |
Like nix_libstore_init, but does not load the Nix configuration.
This is useful when external configuration is not desired, such as when running unit tests.
| nix_err nix_store_copy_closure | ( | nix_c_context * | context, |
| Store * | srcStore, | ||
| Store * | dstStore, | ||
| StorePath * | path ) |
Copy the closure of path from srcStore to dstStore.
| [out] | context | Optional, stores error information |
| [in] | srcStore | nix source store reference |
| [in] | dstStore | nix destination store reference |
| [in] | path | Path to copy |
| void nix_store_free | ( | Store * | store | ) |
Deallocate a nix store and free any resources if not also held by other Store instances.
Does not fail.
| [in] | store | the store to free |
| nix_err nix_store_get_storedir | ( | nix_c_context * | context, |
| Store * | store, | ||
| nix_get_string_callback | callback, | ||
| void * | user_data ) |
get the storeDir of a Nix store, typically "/nix/store"
| [out] | context | Optional, stores error information |
| [in] | store | nix store reference |
| [in] | callback | Called with the URI. |
| [in] | user_data | optional, arbitrary data, passed to the callback when it's called. |
| nix_err nix_store_get_uri | ( | nix_c_context * | context, |
| Store * | store, | ||
| nix_get_string_callback | callback, | ||
| void * | user_data ) |
get the URI of a nix store
| [out] | context | Optional, stores error information |
| [in] | store | nix store reference |
| [in] | callback | Called with the URI. |
| [in] | user_data | optional, arbitrary data, passed to the callback when it's called. |
| nix_err nix_store_get_version | ( | nix_c_context * | context, |
| Store * | store, | ||
| nix_get_string_callback | callback, | ||
| void * | user_data ) |
get the version of a nix store.
If the store doesn't have a version (like the dummy store), returns an empty string.
| [out] | context | Optional, stores error information |
| [in] | store | nix store reference |
| [in] | callback | Called with the version. |
| [in] | user_data | optional, arbitrary data, passed to the callback when it's called. |
| bool nix_store_is_valid_path | ( | nix_c_context * | context, |
| Store * | store, | ||
| StorePath * | path ) |
| Store * nix_store_open | ( | nix_c_context * | context, |
| const char * | uri, | ||
| const char *** | params ) |
Open a nix store.
Store instances may share state and resources behind the scenes.
| [out] | context | Optional, stores error information |
| [in] | uri | URI of the Nix store, copied. If NULL, the store from the settings will be used. Note that "auto" holds a strange middle ground, reading part of the general environment, but not all of it. It ignores NIX_REMOTE and the store option. For this reason, NULL is most likely the better choice. For supported store URLs, see Store URL format in the Nix Reference Manual. |
| [in] | params | optional, null-terminated array of key-value pairs, e.g. {{"endpoint", "https://s3.local"}}. |
| StorePath * nix_store_parse_path | ( | nix_c_context * | context, |
| Store * | store, | ||
| const char * | path ) |
Parse a Nix store path into a StorePath.
| [out] | context | Optional, stores error information |
| [in] | store | nix store reference |
| [in] | path | Path string to parse, copied |
| void nix_store_path_free | ( | StorePath * | p | ) |
| void nix_store_path_name | ( | const StorePath * | store_path, |
| nix_get_string_callback | callback, | ||
| void * | user_data ) |
Get the path name (e.g. "name" in /nix/store/...-name)
| [in] | store_path | the path to get the name from |
| [in] | callback | called with the name |
| [in] | user_data | arbitrary data, passed to the callback when it's called. |
| nix_err nix_store_real_path | ( | nix_c_context * | context, |
| Store * | store, | ||
| StorePath * | path, | ||
| nix_get_string_callback | callback, | ||
| void * | user_data ) |
Get the physical location of a store path.
A store may reside at a different location than its storeDir suggests. This situation is called a relocated store. Relocated stores are used during NixOS installation, as well as in restricted computing environments that don't offer a writable /nix/store.
Not all types of stores support this operation.
| [in] | context | Optional, stores error information |
| [in] | store | nix store reference |
| [in] | path | the path to get the real path from |
| [in] | callback | called with the real path |
| [in] | user_data | arbitrary data, passed to the callback when it's called. |
| nix_err nix_store_realise | ( | nix_c_context * | context, |
| Store * | store, | ||
| StorePath * | path, | ||
| void * | userdata, | ||
| void(* | callback )(void *userdata, const char *outname, const char *out) ) |
Realise a Nix store path.
Blocking, calls callback once for each realised output.
| [out] | context | Optional, stores error information |
| [in] | store | Nix Store reference |
| [in] | path | Path to build |
| [in] | userdata | data to pass to every callback invocation |
| [in] | callback | called for every realised output |