From 1f4420cb4aa3ad6e12af7784827f93c08cf008d8 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 22 Oct 2022 17:57:02 +0300 Subject: feat(tvix/eval): add mechanism for placeholder builtins 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 --- tvix/eval/src/builtins/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tvix') 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 { ] } +/// 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 { + vec![Builtin::new( + "addErrorContext", + &[false, false], + |mut args: Vec, vm: &mut VM| { + vm.emit_warning(WarningKind::NotImplemented("builtins.addErrorContext")); + Ok(args.pop().unwrap()) + }, + )] +} + fn builtins_set() -> NixAttrs { let mut map: BTreeMap = BTreeMap::new(); @@ -652,6 +669,8 @@ fn builtins_set() -> NixAttrs { }; add_builtins(pure_builtins()); + add_builtins(placeholders()); + #[cfg(feature = "impure")] { map.extend(impure::builtins()); -- cgit 1.4.1