Nix 2.29.1
Nix, the purely functional package manager: C API (experimental)
Loading...
Searching...
No Matches
nix_api_expr.h
Go to the documentation of this file.
1#ifndef NIX_API_EXPR_H
2#define NIX_API_EXPR_H
12
13#include "nix_api_store.h"
14#include "nix_api_util.h"
15#include <stddef.h>
16
17#ifndef __has_c_attribute
18# define __has_c_attribute(x) 0
19#endif
20
21#if __has_c_attribute(deprecated)
22# define NIX_DEPRECATED(msg) [[deprecated(msg)]]
23#else
24# define NIX_DEPRECATED(msg)
25#endif
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30// cffi start
31
32// Type definitions
37
46typedef struct EvalState EvalState; // nix::EvalState
47
62typedef struct nix_value nix_value;
63NIX_DEPRECATED("use nix_value instead") typedef nix_value Value;
64
65// Function prototypes
77
92 nix_c_context * context, EvalState * state, const char * expr, const char * path, nix_value * value);
93
107
125 nix_c_context * context, EvalState * state, nix_value * fn, size_t nargs, nix_value ** args, nix_value * value);
126
141#define NIX_VALUE_CALL(context, state, value, fn, ...) \
142 do { \
143 nix_value * args_array[] = {__VA_ARGS__}; \
144 size_t nargs = sizeof(args_array) / sizeof(args_array[0]); \
145 nix_value_call_multi(context, state, fn, nargs, args_array, value); \
146 } while (0)
147
164
180
192
204
213 nix_c_context * context, nix_eval_state_builder * builder, const char ** lookupPath);
214
226
235
247EvalState * nix_state_create(nix_c_context * context, const char ** lookupPath, Store * store);
248
257
271
272// TODO: Deprecate nix_gc_incref in favor of the type-specific reference counting functions?
273// e.g. nix_value_incref.
274// It gives implementors more flexibility, and adds safety, so that generated
275// bindings can be used without fighting the host type system (where applicable).
285nix_err nix_gc_incref(nix_c_context * context, const void * object);
297nix_err nix_gc_decref(nix_c_context * context, const void * object);
298
305
315void nix_gc_register_finalizer(void * obj, void * cd, void (*finalizer)(void * obj, void * cd));
316
318// cffi end
319#ifdef __cplusplus
320}
321#endif
322
324
325#endif // NIX_API_EXPR_H
void nix_gc_register_finalizer(void *obj, void *cd, void(*finalizer)(void *obj, void *cd))
Register a callback that gets called when the object is garbage collected.
nix_err nix_gc_decref(nix_c_context *context, const void *object)
Decrement the garbage collector reference counter for the given object.
void nix_gc_now()
Trigger the garbage collector manually.
nix_err nix_gc_incref(nix_c_context *context, const void *object)
Increment the garbage collector reference counter for the given object.
nix_err
Type for error codes in the Nix system.
Definition nix_api_util.h:59
void nix_eval_state_builder_free(nix_eval_state_builder *builder)
Free a nix_eval_state_builder.
nix_err nix_value_call(nix_c_context *context, EvalState *state, nix_value *fn, nix_value *arg, nix_value *value)
Calls a Nix function with an argument.
nix_err nix_value_force(nix_c_context *context, EvalState *state, nix_value *value)
Forces the evaluation of a Nix value.
nix_err nix_expr_eval_from_string(nix_c_context *context, EvalState *state, const char *expr, const char *path, nix_value *value)
Parses and evaluates a Nix expression from a string.
EvalState * nix_state_create(nix_c_context *context, const char **lookupPath, Store *store)
Create a new Nix language evaluator state.
nix_err nix_libexpr_init(nix_c_context *context)
Initialize the Nix language evaluator.
nix_err nix_eval_state_builder_set_lookup_path(nix_c_context *context, nix_eval_state_builder *builder, const char **lookupPath)
Set the lookup path for <...> expressions.
nix_err nix_value_force_deep(nix_c_context *context, EvalState *state, nix_value *value)
Forces the deep evaluation of a Nix value.
nix_err nix_value_call_multi(nix_c_context *context, EvalState *state, nix_value *fn, size_t nargs, nix_value **args, nix_value *value)
Calls a Nix function with multiple arguments.
nix_eval_state_builder * nix_eval_state_builder_new(nix_c_context *context, Store *store)
Create a new nix_eval_state_builder.
nix_err nix_eval_state_builder_load(nix_c_context *context, nix_eval_state_builder *builder)
Read settings from the ambient environment.
EvalState * nix_eval_state_build(nix_c_context *context, nix_eval_state_builder *builder)
Create a new Nix language evaluator state.
struct nix_value nix_value
A Nix language value, or thunk that may evaluate to a value.
Definition nix_api_expr.h:62
void nix_state_free(EvalState *state)
Frees a Nix state.
struct nix_eval_state_builder nix_eval_state_builder
Builder for EvalState.
Definition nix_api_expr.h:36
struct Store Store
Reference to a Nix store.
Definition nix_api_store.h:23
Main entry for the libstore C bindings.
Main entry for the libutil C bindings.
Represents a state of the Nix language evaluator.
This object stores error state.