about summary refs log tree commit diff
path: root/tvix/cli/src/derivation.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/cli/src/derivation.rs')
-rw-r--r--tvix/cli/src/derivation.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/tvix/cli/src/derivation.rs b/tvix/cli/src/derivation.rs
index 88e87b2f908e..e2184c4a676a 100644
--- a/tvix/cli/src/derivation.rs
+++ b/tvix/cli/src/derivation.rs
@@ -429,7 +429,37 @@ pub use derivation_builtins::builtins as derivation_builtins;
 
 #[cfg(test)]
 mod tests {
+    use crate::known_paths::KnownPaths;
     use nix_compat::store_path::hash_placeholder;
+    use std::{cell::RefCell, rc::Rc};
+
+    #[test]
+    fn derivation() {
+        let mut eval = tvix_eval::Evaluation::new_impure(
+            r#"(derivation { name = "foo"; builder = "/bin/sh"; system = "x86_64-linux";}).outPath"#,
+            None,
+        );
+
+        let known_paths: Rc<RefCell<KnownPaths>> = Default::default();
+
+        eval.builtins
+            .extend(crate::derivation::derivation_builtins(known_paths));
+
+        // Add the actual `builtins.derivation` from compiled Nix code
+        // TODO: properly compose this
+        eval.src_builtins
+            .push(("derivation", include_str!("derivation.nix")));
+
+        let result = eval.evaluate();
+
+        assert!(result.errors.is_empty(), "expect evaluation to succeed");
+        let value = result.value.expect("must be some");
+        // TODO: test this more reliably, derive Eq?
+        assert_eq!(
+            "\"/nix/store/xpcvxsx5sw4rbq666blz6sxqlmsqphmr-foo\"",
+            value.to_string()
+        );
+    }
 
     // TODO: These tests are commented out because we do not have
     // scaffolding to drive generators during testing at the moment.