Nix 2.34.6
Nix, the purely functional package manager: C API (experimental)
Loading...
Searching...
No Matches
Value

nix_value type and core operations for working with Nix values More...

Data Structures

struct  nix_value
 A Nix language value, or thunk that may evaluate to a value. More...

Enumerations

enum  ValueType {
  NIX_TYPE_THUNK , NIX_TYPE_INT , NIX_TYPE_FLOAT , NIX_TYPE_BOOL ,
  NIX_TYPE_STRING , NIX_TYPE_PATH , NIX_TYPE_NULL , NIX_TYPE_ATTRS ,
  NIX_TYPE_LIST , NIX_TYPE_FUNCTION , NIX_TYPE_EXTERNAL , NIX_TYPE_FAILED
}
 Represents the state of a Nix value. More...

Functions

nix_err nix_value_incref (nix_c_context *context, nix_value *value)
 Increment the garbage collector reference counter for the given nix_value.
nix_err nix_value_decref (nix_c_context *context, nix_value *value)
 Decrement the garbage collector reference counter for the given object.

Detailed Description

nix_value type and core operations for working with Nix values

See also
Value Creation
Value Extraction

Enumeration Type Documentation

◆ ValueType

enum ValueType

Represents the state of a Nix value.

Thunk values (NIX_TYPE_THUNK) change to their final, unchanging type when forced.

See also
https://nix.dev/manual/nix/latest/language/evaluation.html
Enumerator
NIX_TYPE_THUNK 

Unevaluated expression

Thunks often contain an expression and closure, but may contain other representations too.

Their state is mutable, unlike that of the other types.

NIX_TYPE_INT 

A 64 bit signed integer.

NIX_TYPE_FLOAT 

IEEE 754 double precision floating point number.

See also
https://nix.dev/manual/nix/latest/language/types.html#type-float
NIX_TYPE_BOOL 

Boolean true or false value.

See also
https://nix.dev/manual/nix/latest/language/types.html#type-bool
NIX_TYPE_STRING 

String value with context.

String content may contain arbitrary bytes, not necessarily UTF-8.

See also
https://nix.dev/manual/nix/latest/language/types.html#type-string
NIX_TYPE_PATH 

Filesystem path.

See also
https://nix.dev/manual/nix/latest/language/types.html#type-path
NIX_TYPE_NULL 

Null value.

See also
https://nix.dev/manual/nix/latest/language/types.html#type-null
NIX_TYPE_ATTRS 

Attribute set (key-value mapping).

See also
https://nix.dev/manual/nix/latest/language/types.html#type-attrs
NIX_TYPE_LIST 

Ordered list of values.

See also
https://nix.dev/manual/nix/latest/language/types.html#type-list
NIX_TYPE_FUNCTION 

Function (lambda or builtin).

See also
https://nix.dev/manual/nix/latest/language/types.html#type-function
NIX_TYPE_EXTERNAL 

External value from C++ plugins or C API.

See also
Externals

Function Documentation

◆ nix_value_decref()

nix_err nix_value_decref ( nix_c_context * context,
nix_value * value )

Decrement the garbage collector reference counter for the given object.

When the counter reaches zero, the nix_value object becomes invalid. The data referenced by nix_value may not be deallocated until the memory garbage collector has run, but deallocation is not guaranteed.

Parameters
[out]contextOptional, stores error information
[in]ValueThe object to stop referencing

◆ nix_value_incref()

nix_err nix_value_incref ( nix_c_context * context,
nix_value * value )

Increment the garbage collector reference counter for the given nix_value.

The Nix language evaluator C API keeps track of alive objects by reference counting. When you're done with a refcounted pointer, call nix_value_decref().

Parameters
[out]contextOptional, stores error information
[in]ValueThe object to keep alive