about summary refs log tree commit diff
path: root/tvix/glue/src/builtins/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/glue/src/builtins/mod.rs')
-rw-r--r--tvix/glue/src/builtins/mod.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/tvix/glue/src/builtins/mod.rs b/tvix/glue/src/builtins/mod.rs
index dff6a8947c16..4a59ec9ea6e5 100644
--- a/tvix/glue/src/builtins/mod.rs
+++ b/tvix/glue/src/builtins/mod.rs
@@ -6,6 +6,7 @@ use crate::tvix_store_io::TvixStoreIO;
 
 mod derivation;
 mod derivation_error;
+mod fetchers;
 
 pub use derivation_error::Error as DerivationError;
 
@@ -17,20 +18,30 @@ pub use derivation_error::Error as DerivationError;
 /// `known_paths`.
 pub fn add_derivation_builtins<IO>(eval: &mut tvix_eval::Evaluation<IO>, io: Rc<TvixStoreIO>) {
     eval.builtins
-        .extend(derivation::derivation_builtins::builtins(io));
+        .extend(derivation::derivation_builtins::builtins(Rc::clone(&io)));
 
     // Add the actual `builtins.derivation` from compiled Nix code
     eval.src_builtins
         .push(("derivation", include_str!("derivation.nix")));
 }
 
+/// Adds fetcher builtins to the passed [tvix_eval::Evaluation]:
+///
+/// * `fetchurl`
+/// * `fetchTarball`
+/// * `fetchGit`
+pub fn add_fetcher_builtins<IO>(eval: &mut tvix_eval::Evaluation<IO>, io: Rc<TvixStoreIO>) {
+    eval.builtins
+        .extend(fetchers::fetcher_builtins::builtins(Rc::clone(&io)));
+}
+
 #[cfg(test)]
 mod tests {
     use std::{rc::Rc, sync::Arc};
 
     use crate::tvix_store_io::TvixStoreIO;
 
-    use super::add_derivation_builtins;
+    use super::{add_derivation_builtins, add_fetcher_builtins};
     use nix_compat::store_path::hash_placeholder;
     use test_case::test_case;
     use tvix_build::buildservice::DummyBuildService;
@@ -57,7 +68,8 @@ mod tests {
 
         let mut eval = tvix_eval::Evaluation::new(io.clone() as Rc<dyn EvalIO>, false);
 
-        add_derivation_builtins(&mut eval, io);
+        add_derivation_builtins(&mut eval, Rc::clone(&io));
+        add_fetcher_builtins(&mut eval, io);
 
         // run the evaluation itself.
         eval.evaluate(str, None)