refactor(tvix/eval): insert storeDir "builtin" in eval startup

Instead of using a suspended native thunk, calculate and optionally
insert the storeDir builtin when the VM is constructed.

We already have the IO handle available at this point and can just
check whether a storeDir is present, and insert its absolute value as
a builtin.

Change-Id: If966eee6ff26dc888b6e888e7c46170c0c346b05
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8145
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Tested-by: BuildkiteCI
This commit is contained in:
Vincent Ambo 2023-02-26 18:31:59 +03:00 committed by tazjin
parent e1f082a3ab
commit 38fd3cb292
2 changed files with 5 additions and 10 deletions

View file

@ -66,16 +66,6 @@ mod impure_builtins {
pub fn impure_builtins() -> Vec<(&'static str, Value)> {
let mut result = impure_builtins::builtins();
result.push((
"storeDir",
Value::Thunk(Thunk::new_suspended_native(Box::new(
|vm: &mut VM| match vm.io().store_dir() {
None => Ok(Value::Null),
Some(dir) => Ok(Value::String(dir.into())),
},
))),
));
// currentTime pins the time at which evaluation was started
{
let seconds = match SystemTime::now().duration_since(UNIX_EPOCH) {