add builder pattern for tvix_eval::Evaluation, allow passing in config to tvix_serde
Currently, tvix_serde creates an evaluation object with the passed source code and immediately starts to evaluate:
let eval = tvix_eval::Evaluation::new(src, None); let source = eval.source_map(); let result = eval.evaluate(); if !result.errors.is_empty() { return Err(Error::NixErrors { errors: result.errors, source, }); }
This means, it's not possible to pass in custom builtins etc.
It might make more sense to have tvix_eval provide a Builder Pattern to assemble EvalConfig
, containing all this config, and consume such a config in tvix_serde.
We could also expose a "pure eval, no IO, no build/store related builtins" default config (by implementing Default
.
That way, WASM or serde clients could just say EvalConfig::default()
, and the CLI could compose another one.
After playing with these thoughts a bit, I think we want to have a longer-living
struct Evaluator
struct, that is constructed from aEvalBuilder::build()
. config inEvaluator
should be considered immutable after creation.We could then move
compile_only
andevaluate
toEvaluator::{compile_only,evaluate}
, and add the attribute path/source code to the function arguments - probably together with optional observer(s) - but these could be called without consumingself
.This should open up possibilities to longer-running evaluators, some simple LSP workloads etc - and we could pass such an Evaluator into tvix-serde - and derive Default, if we want to.
flokli at 2023-05-27T17·23+00
This should probably allow setting
NIX_PATH
elements. We also might want to support some feature for bundling stuff likelib
, as that can be very useful without the wider nixpkgs context.tazjin at 2023-06-16T11·18+00
Fixed by cl/8808
tazjin at 2023-06-16T11·53+00
It's more of a workaround. I'd still think the builder pattern would be a bit more ergonomic.
flokli at 2023-06-16T12·04+00
This should probably live in tvix-glue, and we should have some functions that make the whole known paths thing less annoying.
flokli at 2023-11-03T12·12+00
claim
aspen at 2024-07-06T00·11+00
https://cl.tvl.fyi/c/depot/+/11956
aspen at 2024-07-06T00·39+00
- aspen closed this issue at 2024-08-18T20·39+00