Expand description
Tree-walking evaluator using rnix’s typed AST. Tree-walking Nix evaluator using rnix’s typed AST.
Implements Tvix-style lazy evaluation with thunks: let-bindings and
rec-attrset values are wrapped in Value::Thunk and only evaluated
when their value is actually needed (call-by-need with memoization).
Structs§
- Eval
File Guard - RAII guard that pops the top of the eval-file stack on drop.
- Source
IdGuard - RAII guard that restores the previous
CURRENT_SOURCE_IDon drop.
Enums§
- NixTrace
Frame - A single frame in the Nix-level error trace.
Functions§
- apply
- apply_
and_ force - Apply a function to an argument.
- attach_
trace - Capture the current Nix trace and attach it to an error.
- current_
eval_ dir - Return the directory of the file currently being evaluated, if any.
Used by the
PathRelAST handler to resolve relative path literals. - current_
eval_ file - Return the file currently being evaluated, if any. Used by error sites to attach source location context.
- dump_
force_ sites - Dump force-site counters (call from perf reporting).
- eval
- Evaluate a Nix expression string.
- eval_
expr - Evaluate an rnix expression in an environment.
- eval_
file_ stack_ snapshot - Snapshot the entire eval file stack (debug).
- eval_
plan_ group - Build an attrset from a
sui-normalize[GroupPlan]. - eval_
with_ file - Evaluate a Nix expression string, optionally tagged with the
path of the source file. The file is stored on the root
Envso that any closure created during evaluation captures it and can resolve relative path literals (./foo.nix) in function defaults that fire after control has left the file’s scope. - force_
concrete - Force a value: if it is a thunk, evaluate and memoize the result. Concrete values are returned unchanged. Force a value: if it is a thunk, evaluate and memoize the result. Concrete values are returned unchanged.
- force_
value - Force a value (legacy API — returns
Valuefor backward compatibility). - force_
value_ tracked - Force with call-site tracking (legacy API).
- is_
pure_ mode - Whether the current thread is in hermetic (pure) evaluation mode.
- normalize_
path - Normalize a path by removing
.and resolving..components without touching the filesystem. - push_
eval_ file - Push a file onto the eval stack. Returns an RAII guard that pops
it on drop. Use when entering an
import <file>so subsequent relative path literals resolve against the right directory. - push_
eval_ frame - Push a frame that may be fileless.
Nonemeans “this code has no source file” and MUST still occupy a stack slot — pushing nothing would leave the caller’s file visible tocurrent_eval_file, which is exactly theunsafeGetAttrPosdivergence documented onEVAL_FILE_STACK. - push_
source_ id - Set
CURRENT_SOURCE_IDtoid, returning an RAII guard that restores the previous id on drop. Used at thunk force so a cross-file thunk’s idents key the(source_id, offset)symbol cache against the file where the thunk was DEFINED, not the ambient source at force time — the sibling of the eval-file guard, closing theparse.nixcross-file collision. - set_
pure_ mode - Enable or disable hermetic (pure) evaluation mode for the current thread.