Nix 2.17.0
Nix, the purely functional package manager; stable external interfaces
Loading...
Searching...
No Matches
libstore

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. More...
 
nix_err nix_init_plugins (nix_c_context *context)
 Loads plugins specified in the settings. More...
 
Storenix_store_open (nix_c_context *, const char *uri, const char ***params)
 Open a nix store. More...
 
void nix_store_unref (Store *store)
 Unref a nix store. More...
 
nix_err nix_store_get_uri (nix_c_context *context, Store *store, char *dest, unsigned int n)
 get the URI of a nix store More...
 
StorePathnix_store_parse_path (nix_c_context *context, Store *store, const char *path)
 parse a nix store path into a StorePath More...
 
void nix_store_path_free (StorePath *p)
 Deallocate a nix StorePath. More...
 
bool nix_store_is_valid_path (nix_c_context *context, Store *store, StorePath *path)
 check if a storepath is valid (exists in the store) More...
 
nix_err nix_store_build (nix_c_context *context, Store *store, StorePath *path, void *userdata, void(*cb)(void *userdata, const char *outname, const char *out))
 Build a nix store path. More...
 
nix_err nix_store_get_version (nix_c_context *, Store *store, char *dest, unsigned int n)
 get the version of a nix store More...
 

Detailed Description

C bindings for nix libstore.

libstore is used for talking to a Nix store

Function Documentation

◆ nix_init_plugins()

nix_err nix_init_plugins ( nix_c_context context)

Loads plugins specified in the settings.

Call this once, after calling your desired init functions and setting relevant settings.

Parameters
[out]contextOptional, stores error information
Returns
NIX_OK if the initialization was successful, an error code otherwise.

◆ nix_libstore_init()

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.

Parameters
[out]contextOptional, stores error information
Returns
NIX_OK if the initialization was successful, an error code otherwise.

◆ nix_store_build()

nix_err nix_store_build ( nix_c_context context,
Store store,
StorePath path,
void *  userdata,
void(*)(void *userdata, const char *outname, const char *out)  cb 
)

Build a nix store path.

Blocking, calls cb once for each built output

Parameters
[out]contextOptional, stores error information
[in]storenix store reference
[in]pathPath to build
[in]userdatadata to pass to every callback invocation
[in]cbcalled for every built output

◆ nix_store_get_uri()

nix_err nix_store_get_uri ( nix_c_context context,
Store store,
char *  dest,
unsigned int  n 
)

get the URI of a nix store

Parameters
[out]contextOptional, stores error information
[in]storenix store reference
[out]destThe allocated area to write the string to.
[in]nMaximum size of the returned string.
Returns
error code, NIX_OK on success.

◆ nix_store_get_version()

nix_err nix_store_get_version ( nix_c_context ,
Store store,
char *  dest,
unsigned int  n 
)

get the version of a nix store

Parameters
[out]contextOptional, stores error information
[in]storenix store reference
[out]destThe allocated area to write the string to.
[in]nMaximum size of the returned string.
Returns
error code, NIX_OK on success.

◆ nix_store_is_valid_path()

bool nix_store_is_valid_path ( nix_c_context context,
Store store,
StorePath path 
)

check if a storepath is valid (exists in the store)

Parameters
[out]contextOptional, stores error information
[in]storenix store reference
[in]pathPath to check
Returns
true or false, error info in context

◆ nix_store_open()

Store * nix_store_open ( nix_c_context ,
const char *  uri,
const char ***  params 
)

Open a nix store.

Parameters
[out]contextOptional, stores error information
[in]uriURI of the nix store, copied
[in]paramsoptional, array of key-value pairs, {{"endpoint", "https://s3.local"}}
Returns
ref-counted Store pointer, NULL in case of errors
See also
nix_store_unref

◆ nix_store_parse_path()

StorePath * nix_store_parse_path ( nix_c_context context,
Store store,
const char *  path 
)

parse a nix store path into a StorePath

Don't forget to free this path using nix_store_path_free

Parameters
[out]contextOptional, stores error information
[in]storenix store reference
[in]pathPath string to parse, copied
Returns
owned store path, NULL on error

◆ nix_store_path_free()

void nix_store_path_free ( StorePath p)

Deallocate a nix StorePath.

Does not fail.

Parameters
[in]pthe path to free

◆ nix_store_unref()

void nix_store_unref ( Store store)

Unref a nix store.

Does not fail. It'll be closed and deallocated when all references are gone.

Parameters
[in]builderthe store to unref