diff options
author | Evgeny Zemtsov <eze@resoptima.com> | 2023-06-22T15·57+0200 |
---|---|---|
committer | ezemtsov <eugene.zemtsov@gmail.com> | 2023-06-22T20·19+0000 |
commit | c8fcdca4eb09709966ea25883cbe91f34c038236 (patch) | |
tree | 52dfa7ab1bbc8f9afdb1e94c130fe6cd70c4bb35 /tvix/eval | |
parent | 8cdad7d45c6c58f0b93f0ca5b4779e31bd845bb9 (diff) |
feat(tvix/eval): allow extending builtins outside of tvix_eval r/6344
The change allows applications that use tvix_serde for parsing nix-based configuration to extend the language with domain-specific set of features. Change-Id: Ia86612308a167c456ecf03e93fe0fbae55b876a6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8848 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval')
-rw-r--r-- | tvix/eval/builtin-macros/src/lib.rs | 14 | ||||
-rw-r--r-- | tvix/eval/src/builtins/impure.rs | 1 | ||||
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 1 | ||||
-rw-r--r-- | tvix/eval/src/tests/mod.rs | 1 |
4 files changed, 9 insertions, 8 deletions
diff --git a/tvix/eval/builtin-macros/src/lib.rs b/tvix/eval/builtin-macros/src/lib.rs index dfd0948c7d9f..e2cd51b92451 100644 --- a/tvix/eval/builtin-macros/src/lib.rs +++ b/tvix/eval/builtin-macros/src/lib.rs @@ -116,10 +116,8 @@ fn parse_module_args(args: TokenStream) -> Option<Type> { /// /// # Examples /// ```ignore +/// # use tvix_eval; /// # use tvix_eval_builtin_macros::builtins; -/// # mod value { -/// # pub use tvix_eval::Builtin; -/// # } /// /// #[builtins] /// mod builtins { @@ -270,7 +268,7 @@ pub fn builtins(args: TokenStream, item: TokenStream) -> TokenStream { if arg.strict { f.block = Box::new(parse_quote_spanned! {arg.span=> { - let #ident: #ty = generators::request_force(&co, values.pop() + let #ident: #ty = tvix_eval::generators::request_force(&co, values.pop() .expect("Tvix bug: builtin called with incorrect number of arguments")).await; #block @@ -295,20 +293,20 @@ pub fn builtins(args: TokenStream, item: TokenStream) -> TokenStream { if captures_state { builtins.push(quote_spanned! { builtin_attr.span() => { let inner_state = state.clone(); - crate::Builtin::new( + tvix_eval::Builtin::new( #name, #docstring, #arg_count, - move |values| Gen::new(|co| generators::pin_generator(#fn_name(inner_state.clone(), co, values))), + move |values| Gen::new(|co| tvix_eval::generators::pin_generator(#fn_name(inner_state.clone(), co, values))), ) }}); } else { builtins.push(quote_spanned! { builtin_attr.span() => { - crate::Builtin::new( + tvix_eval::Builtin::new( #name, #docstring, #arg_count, - |values| Gen::new(|co| generators::pin_generator(#fn_name(co, values))), + |values| Gen::new(|co| tvix_eval::generators::pin_generator(#fn_name(co, values))), ) }}); } diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs index adf43e1a2ea9..cf3186ce5087 100644 --- a/tvix/eval/src/builtins/impure.rs +++ b/tvix/eval/src/builtins/impure.rs @@ -7,6 +7,7 @@ use std::{ }; use crate::{ + self as tvix_eval, errors::ErrorKind, io::FileType, value::NixAttrs, diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index b5c7931768e9..c841f9fc6a29 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -16,6 +16,7 @@ use crate::value::PointerEquality; use crate::vm::generators::{self, GenCo}; use crate::warnings::WarningKind; use crate::{ + self as tvix_eval, errors::ErrorKind, value::{CoercionKind, NixAttrs, NixList, NixString, SharedThunkSet, Thunk, Value}, }; diff --git a/tvix/eval/src/tests/mod.rs b/tvix/eval/src/tests/mod.rs index f800baf05018..02227a7e9a2d 100644 --- a/tvix/eval/src/tests/mod.rs +++ b/tvix/eval/src/tests/mod.rs @@ -10,6 +10,7 @@ mod one_offs; mod mock_builtins { //! Builtins which are required by language tests, but should not //! actually exist in //tvix/eval. + use crate as tvix_eval; use crate::generators::GenCo; use crate::*; use genawaiter::rc::Gen; |