Nix 2.36.0
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
15
16#include "nix_api_store.h"
17#include "nix_api_util.h"
18#include <stddef.h>
19
20#ifndef __has_c_attribute
21# define __has_c_attribute(x) 0
22#endif
23
24#if __has_c_attribute(deprecated)
25# define NIX_DEPRECATED(msg) [[deprecated(msg)]]
26#else
27# define NIX_DEPRECATED(msg)
28#endif
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33// cffi start
34
35// Type definitions
40
49typedef struct EvalState EvalState; // nix::EvalState
50
52
69typedef struct nix_value nix_value;
70NIX_DEPRECATED("use nix_value instead") typedef nix_value Value;
71
72// Function prototypes
85
101 nix_c_context * context, EvalState * state, const char * expr, const char * path, nix_value * value);
102
117
136 nix_c_context * context, EvalState * state, nix_value * fn, size_t nargs, nix_value ** args, nix_value * value);
137
154#define NIX_VALUE_CALL(context, state, value, fn, ...) \
155 do { \
156 nix_value * args_array[] = {__VA_ARGS__}; \
157 size_t nargs = sizeof(args_array) / sizeof(args_array[0]); \
158 nix_value_call_multi(context, state, fn, nargs, args_array, value); \
159 } while (0)
160
178
194
207
220
230 nix_c_context * context, nix_eval_state_builder * builder, const char ** lookupPath);
231
245 nix_c_context * context, nix_eval_state_builder * builder, const char * key, const char * value);
246
260
270
283EvalState * nix_state_create(nix_c_context * context, const char ** lookupPath, Store * store);
284
294
309
310// TODO: Deprecate nix_gc_incref in favor of the type-specific reference counting functions?
311// e.g. nix_value_incref.
312// It gives implementors more flexibility, and adds safety, so that generated
313// bindings can be used without fighting the host type system (where applicable).
323nix_err nix_gc_incref(nix_c_context * context, const void * object);
338nix_err nix_gc_decref(nix_c_context * context, const void * object);
339
346
356void nix_gc_register_finalizer(void * obj, void * cd, void (*finalizer)(void * obj, void * cd));
357 // doxygen group GC
359
365
391StorePath *
392nix_get_derivation(nix_c_context * context, EvalState * state, nix_value * value, bool ignoreAssertionFailures);
393
419 nix_c_context * context, EvalState * state, nix_value * auto_args, nix_value * fn_val, nix_value * result);
420 // doxygen group libexpr_eval
422
423// cffi end
424#ifdef __cplusplus
425}
426#endif
427
428#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
nix_err nix_value_auto_call_function(nix_c_context *context, EvalState *state, nix_value *auto_args, nix_value *fn_val, nix_value *result)
Call a function, drawing its arguments from an attribute set.
StorePath * nix_get_derivation(nix_c_context *context, EvalState *state, nix_value *value, bool ignoreAssertionFailures)
Determine whether a Nix value is a derivation and, if so, return its store derivation path.
void nix_eval_state_builder_free(nix_eval_state_builder *builder)
Free a nix_eval_state_builder.
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_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.
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:39
nix_err nix_eval_state_builder_set_setting(nix_c_context *context, nix_eval_state_builder *builder, const char *key, const char *value)
Set an evaluator setting on the builder.
struct Store Store
Reference to a Nix store.
Definition nix_api_store.h:25
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.
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_err nix_value_force_deep(nix_c_context *context, EvalState *state, nix_value *value)
Forces the deep evaluation of a Nix value.
Main entry for the libstore C bindings.
Main entry for the libutil C bindings.
nix_value Value
Definition nix_api_value.h:112
Represents a state of the Nix language evaluator.
This object stores error state.
A Nix language value, or thunk that may evaluate to a value.