Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::EvalState Class Reference

Public Member Functions

 EvalState (const EvalState &)=delete
 EvalState (EvalState &&)=delete
EvalState & operator= (const EvalState &)=delete
EvalState & operator= (EvalState &&)=delete
void evalFile (const SourcePath &path, Value &v)
void resetFileCache ()
void eval (Expr &e, Value &v)
bool evalBool (Env &env, Expr &e)
void evalAttrs (Env &env, Expr &e, Value &v)
void evalList (Env &env, Expr &e, Value &v)
void forceValue (Value &v, const PosIdx pos)
void tryFixupBlackHolePos (Value &v, PosIdx pos)
void forceValueDeep (Value &v)
NixInt forceInt (Value &v, const PosIdx pos, std::string_view errorCtx)
NixFloat forceFloat (Value &v, const PosIdx pos, std::string_view errorCtx)
bool forceBool (Value &v, const PosIdx pos, std::string_view errorCtx)
void forceAttrs (Value &v, const PosIdx pos, std::string_view errorCtx)
void forceList (Value &v, const PosIdx pos, std::string_view errorCtx)
void forceFunction (Value &v, const PosIdx pos, std::string_view errorCtx)
std::string_view forceString (Value &v, const PosIdx pos, std::string_view errorCtx)
std::string_view forceString (Value &v, NixStringContext &context, const PosIdx pos, std::string_view errorCtx)
std::string_view forceStringNoCtx (Value &v, const PosIdx pos, std::string_view errorCtx)
StringMap realiseContext (const NixStringContext &context)
bool isDerivation (Value &v)
std::optional< std::string > tryAttrsToString (const PosIdx pos, Value &v, NixStringContext &context, bool coerceMore=false, bool copyToStore=true)
BackedStringView coerceToString (const PosIdx pos, Value &v, NixStringContext &context, std::string_view errorCtx, bool coerceMore=false, bool copyToStore=true, bool canonicalizePath=true)
SourcePath coerceToPath (const PosIdx pos, Value &v, NixStringContext &context, std::string_view errorCtx)
StorePath coerceToStorePath (const PosIdx pos, Value &v, NixStringContext &context, std::string_view errorCtx)
std::pair< SingleDerivedPath, std::string_view > coerceToSingleDerivedPathUnchecked (const PosIdx pos, Value &v, std::string_view errorCtx)
SingleDerivedPath coerceToSingleDerivedPath (const PosIdx pos, Value &v, std::string_view errorCtx)
bool eqValues (Value &v1, Value &v2, const PosIdx pos, std::string_view errorCtx)
bool isFunctor (Value &fun)
void callFunction (Value &fun, size_t nrArgs, Value **args, Value &vRes, const PosIdx pos)
void callFunction (Value &fun, Value &arg, Value &vRes, const PosIdx pos)
void autoCallFunction (Bindings &args, Value &fun, Value &res, PosIdx pos)
void mkPos (Value &v, PosIdx pos)
void mkOutputString (Value &value, const SingleDerivedPath::Built &b, std::optional< StorePath > optStaticOutputPath, const ExperimentalFeatureSettings &xpSettings=experimentalFeatureSettings)
void mkSingleDerivedPathString (const SingleDerivedPath &p, Value &v)
void concatLists (Value &v, size_t nrLists, Value **lists, const PosIdx pos, std::string_view errorCtx)

Public Attributes

Evaluator & ctx
AsyncIoRootaio

Friends

class Evaluator
struct ExprVar
struct ExprSet
struct ExprLet

Member Function Documentation

◆ autoCallFunction()

void nix::EvalState::autoCallFunction ( Bindings & args,
Value & fun,
Value & res,
PosIdx pos )

Automatically call a function for which each argument has a default value or has a binding in the args map.

◆ coerceToPath()

SourcePath nix::EvalState::coerceToPath ( const PosIdx pos,
Value & v,
NixStringContext & context,
std::string_view errorCtx )

Path coercion.

Converts strings, paths and derivations to a path. The result is guaranteed to be a canonicalised, absolute path. Nothing is copied to the store.

◆ coerceToSingleDerivedPath()

SingleDerivedPath nix::EvalState::coerceToSingleDerivedPath ( const PosIdx pos,
Value & v,
std::string_view errorCtx )

Coerce to SingleDerivedPath.

Must be a string which is either a literal store path or a "placeholder (see DownstreamPlaceholder).

Even more importantly, the string context must be exactly one element, which is either a NixStringContextElem::Opaque or NixStringContextElem::Built. (NixStringContextEleme::DrvDeep is not permitted).

The string is parsed based on the context — the context is the source of truth, and ultimately tells us what we want, and then we ensure the string corresponds to it.

◆ coerceToSingleDerivedPathUnchecked()

std::pair< SingleDerivedPath, std::string_view > nix::EvalState::coerceToSingleDerivedPathUnchecked ( const PosIdx pos,
Value & v,
std::string_view errorCtx )

Part of coerceToSingleDerivedPath() without any store IO which is exposed for unit testing only.

◆ coerceToStorePath()

StorePath nix::EvalState::coerceToStorePath ( const PosIdx pos,
Value & v,
NixStringContext & context,
std::string_view errorCtx )

Like coerceToPath, but the result must be a store path.

◆ coerceToString()

BackedStringView nix::EvalState::coerceToString ( const PosIdx pos,
Value & v,
NixStringContext & context,
std::string_view errorCtx,
bool coerceMore = false,
bool copyToStore = true,
bool canonicalizePath = true )

String coercion.

Converts strings, paths and derivations to a string. If coerceMore is set, also converts nulls, integers, booleans and lists to a string. If copyToStore is set, referenced paths are copied to the Nix store as a side effect.

◆ eqValues()

bool nix::EvalState::eqValues ( Value & v1,
Value & v2,
const PosIdx pos,
std::string_view errorCtx )

Do a deep equality test between two values. That is, list elements and attributes are compared recursively.

◆ eval()

void nix::EvalState::eval ( Expr & e,
Value & v )

Evaluate an expression to normal form

Parameters
[out]vThe resulting is stored here.

◆ evalBool()

bool nix::EvalState::evalBool ( Env & env,
Expr & e )
inline

Evaluation the expression, then verify that it has the expected type.

◆ evalFile()

void nix::EvalState::evalFile ( const SourcePath & path,
Value & v )

Evaluate an expression read from the given file to normal form.

◆ forceFunction()

void nix::EvalState::forceFunction ( Value & v,
const PosIdx pos,
std::string_view errorCtx )
Parameters
veither lambda or primop

◆ forceInt()

NixInt nix::EvalState::forceInt ( Value & v,
const PosIdx pos,
std::string_view errorCtx )

Force v, and then verify that it has the expected type.

◆ forceValue()

void nix::EvalState::forceValue ( Value & v,
const PosIdx pos )
inline

If v is a thunk, enter it and overwrite v with the result of the evaluation of the thunk. If v is a delayed function application, call the function and overwrite v with the result. Otherwise, this is a no-op.

◆ forceValueDeep()

void nix::EvalState::forceValueDeep ( Value & v)

Force a value, then recursively force list elements and attributes.

◆ isDerivation()

bool nix::EvalState::isDerivation ( Value & v)
Returns
true iff the value v denotes a derivation (i.e. a set with attribute type = "derivation").

◆ mkOutputString()

void nix::EvalState::mkOutputString ( Value & value,
const SingleDerivedPath::Built & b,
std::optional< StorePath > optStaticOutputPath,
const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings )

Create a string representing a SingleDerivedPath::Built.

The string is the printed store path with a context containing a single NixStringContextElem::Built element of the drv path and output name.

Parameters
valueValue we are settings
bthe drv whose output we are making a string for, and the output
optStaticOutputPathOptional output path for that string. Must be passed if and only if output store object is input-addressed or fixed output. Will be printed to form string if passed, otherwise a placeholder will be used (see DownstreamPlaceholder).
xpSettingsStop-gap to avoid globals during unit tests.

◆ mkSingleDerivedPathString()

void nix::EvalState::mkSingleDerivedPathString ( const SingleDerivedPath & p,
Value & v )

Create a string representing a SingleDerivedPath.

A combination of mkStorePathString and mkOutputString.

◆ realiseContext()

StringMap nix::EvalState::realiseContext ( const NixStringContext & context)
nodiscard

Realise the given context, and return a mapping from the placeholders used to construct the associated value to their final store path


The documentation for this class was generated from the following files: