pub fn eval_file(path: &Path) -> Result<EvalResult, FileEvalError>Expand description
Compile and execute a Nix file on the bytecode VM, with no fallback.
The file-shaped sibling of eval_full, and the entry point the nix
language corpus needs: until now the only way to run the VM over a file was
through the CLI’s VM arm, which re-runs the whole expression on the
tree-walker the moment the VM errors — so a corpus driven through it would
have measured the walker on both sides.
Two things make this different from eval_full(&read_to_string(path)):
- Base directory. Relative paths (
./foo.nix,import ./lib) resolve against the file’s own directory viaCompiler::compile_with_base_dir— which, before this function, had no call site anywhere in the workspace. - No compile cache.
eval_fullkeys its thread-local cache on the source text; two different files with identical text would share a chunk compiled against the first one’s base directory. Corpus fixtures are small and duplicates are plausible, so this path compiles fresh.
There is deliberately no fallback arm. Fallback still exists below this
call — at the imported-file and builtin boundaries inside the VM — and
SUI_VM_STRICT=1 is what turns the two failure-shaped ones into errors; see
fallback. A caller measuring VM coverage must set it, or the answer it
reads may be the walker’s.
§Errors
FileEvalError::Read if the file cannot be read, otherwise the compile or
runtime error, unmodified.