about summary refs log tree commit diff
path: root/tvix/glue
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/glue')
-rw-r--r--tvix/glue/src/lib.rs10
-rw-r--r--tvix/glue/src/tvix_io.rs4
2 files changed, 12 insertions, 2 deletions
diff --git a/tvix/glue/src/lib.rs b/tvix/glue/src/lib.rs
index acb81d31445f..760e730217ee 100644
--- a/tvix/glue/src/lib.rs
+++ b/tvix/glue/src/lib.rs
@@ -26,3 +26,13 @@ pub fn add_derivation_builtins(
     eval.src_builtins
         .push(("derivation", include_str!("derivation.nix")));
 }
+
+/// Tell the Evaluator to resolve <nix> to the path `/__corepkgs__`,
+/// which has special handling in [tvix_io::TvixIO].
+/// This is used in nixpkgs to import `fetchurl.nix` from `<nix>`.
+pub fn configure_nix_path(eval: &mut tvix_eval::Evaluation, nix_search_path: &Option<String>) {
+    eval.nix_path = nix_search_path
+        .as_ref()
+        .map(|p| format!("nix=/__corepkgs__:{}", p))
+        .or_else(|| Some("nix=/__corepkgs__".to_string()));
+}
diff --git a/tvix/glue/src/tvix_io.rs b/tvix/glue/src/tvix_io.rs
index caadbeb5e663..09e1417a2157 100644
--- a/tvix/glue/src/tvix_io.rs
+++ b/tvix/glue/src/tvix_io.rs
@@ -59,8 +59,8 @@ impl<T: EvalIO> EvalIO for TvixIO<T> {
 
     fn read_to_string(&self, path: &Path) -> Result<String, io::Error> {
         // Bundled version of corepkgs/fetchurl.nix. The counterpart
-        // of this happens in `main`, where the `nix_path` of the
-        // evaluation has `nix=/__corepkgs__` added to it.
+        // of this happens in [crate::configure_nix_path], where the `nix_path`
+        // of the evaluation has `nix=/__corepkgs__` added to it.
         //
         // This workaround is similar to what cppnix does for passing
         // the path through.