diff options
author | Vincent Ambo <mail@tazj.in> | 2022-10-22T14·57+0300 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2022-10-23T15·50+0000 |
commit | 1f4420cb4aa3ad6e12af7784827f93c08cf008d8 (patch) | |
tree | f36702e6a005b124e927e97826b5fbd38b641c69 /tvix/eval/src/builtins | |
parent | 546fcf51cd0b0837604b5c094199d3221173d02f (diff) |
feat(tvix/eval): add mechanism for placeholder builtins r/5181
These are builtins which can be basically implemented as the identity function from the perspective of pure evaluation, and which help us get closer to evaluating nixpkgs. For now, builtins added here will be "usable" and just emit a warning about not being implemented yet. Change-Id: I0fce94677f01c98c0392aeefb7ab353c7dc7ec82 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7060 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to '')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index 14eb673f7815..073edf8ffb7a 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -9,6 +9,7 @@ use std::path::PathBuf; use regex::Regex; +use crate::warnings::WarningKind; use crate::{ errors::ErrorKind, value::{Builtin, CoercionKind, NixAttrs, NixList, NixString, Value}, @@ -636,6 +637,22 @@ fn pure_builtins() -> Vec<Builtin> { ] } +/// Placeholder builtins that technically have a function which we do +/// not yet implement, but which is also not easily observable from +/// within a pure evaluation context. +/// +/// These are used as a crutch to make progress on nixpkgs evaluation. +fn placeholders() -> Vec<Builtin> { + vec![Builtin::new( + "addErrorContext", + &[false, false], + |mut args: Vec<Value>, vm: &mut VM| { + vm.emit_warning(WarningKind::NotImplemented("builtins.addErrorContext")); + Ok(args.pop().unwrap()) + }, + )] +} + fn builtins_set() -> NixAttrs { let mut map: BTreeMap<NixString, Value> = BTreeMap::new(); @@ -652,6 +669,8 @@ fn builtins_set() -> NixAttrs { }; add_builtins(pure_builtins()); + add_builtins(placeholders()); + #[cfg(feature = "impure")] { map.extend(impure::builtins()); |