about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/Cargo.toml5
-rw-r--r--tvix/eval/src/builtins/impure.rs7
-rw-r--r--tvix/eval/src/builtins/mod.rs14
3 files changed, 23 insertions, 3 deletions
diff --git a/tvix/eval/Cargo.toml b/tvix/eval/Cargo.toml
index bf34159656aa..b23fc057ad5a 100644
--- a/tvix/eval/Cargo.toml
+++ b/tvix/eval/Cargo.toml
@@ -39,7 +39,7 @@ itertools = "0.10.3"
 tempdir = "0.3.7"
 
 [features]
-default = [ "repl", "arbitrary" ]
+default = [ "repl", "impure", "arbitrary" ]
 
 # Enables running the Nix language test suite from the original C++
 # Nix implementation (at version 2.3) against Tvix.
@@ -48,6 +48,9 @@ nix_tests = []
 # Enables building the binary (tvix-eval REPL)
 repl = [ "dep:rustyline", "dep:clap" ]
 
+# Enables operations in the VM which depend on the ability to perform I/O
+impure = []
+
 # Enables Arbitrary impls for internal types (required to run tests)
 arbitrary = [ "proptest", "test-strategy" ]
 
diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs
new file mode 100644
index 000000000000..3438aa06f424
--- /dev/null
+++ b/tvix/eval/src/builtins/impure.rs
@@ -0,0 +1,7 @@
+use crate::value::Builtin;
+
+/// Return all impure builtins, that is all builtins which may perform I/O outside of the VM and so
+/// cannot be used in all contexts (e.g. WASM).
+pub(super) fn builtins() -> Vec<Builtin> {
+    vec![]
+}
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index 55135c4d8d45..f40c6f9574b1 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -20,6 +20,8 @@ use crate::arithmetic_op;
 
 use self::versions::{VersionPart, VersionPartsIter};
 
+#[cfg(feature = "impure")]
+mod impure;
 pub mod versions;
 
 /// Coerce a Nix Value to a plain path, e.g. in order to access the file it
@@ -292,8 +294,16 @@ fn pure_builtins() -> Vec<Builtin> {
 fn builtins_set() -> NixAttrs {
     let mut map: BTreeMap<NixString, Value> = BTreeMap::new();
 
-    for builtin in pure_builtins() {
-        map.insert(builtin.name().into(), Value::Builtin(builtin));
+    let mut add_builtins = |builtins: Vec<Builtin>| {
+        for builtin in builtins {
+            map.insert(builtin.name().into(), Value::Builtin(builtin));
+        }
+    };
+
+    add_builtins(pure_builtins());
+    #[cfg(feature = "impure")]
+    {
+        add_builtins(impure::builtins());
     }
 
     NixAttrs::from_map(map)