about summary refs log tree commit diff
path: root/tvix/glue/src/builtins
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2024-04-03T13·08+0200
committerraitobezarius <tvl@lahfa.xyz>2024-04-03T23·23+0000
commite9a23bb4782615722374e7bec643cba669a492bc (patch)
treeeec376d8f63744579cfe64079db7db9c68a089bd /tvix/glue/src/builtins
parent3821fd4224c066c40fc492c8b049bd47c9a212fa (diff)
fix(tvix/glue): produce context for `builtins.(path|filterSource)` r/7850
Fixes b/392.

Output paths were created, depending on a plain store path but no
context string was attached to track that plain dependency.

Context string propagation tests are strengthened to prevent any
regression on this.

Change-Id: Ifd6671aeba6949324b0bb9f0f766b87db728d484
Signed-off-by: Ryan Lahfa <tvl@lahfa.xyz>
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11351
Reviewed-by: Alyssa Ross <hi@alyssa.is>
Tested-by: BuildkiteCI
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/glue/src/builtins')
-rw-r--r--tvix/glue/src/builtins/import.rs19
1 files changed, 15 insertions, 4 deletions
diff --git a/tvix/glue/src/builtins/import.rs b/tvix/glue/src/builtins/import.rs
index fd791b8091..2f02cd6ebb 100644
--- a/tvix/glue/src/builtins/import.rs
+++ b/tvix/glue/src/builtins/import.rs
@@ -123,6 +123,7 @@ mod import_builtins {
     use nix_compat::nixhash::{CAHash, NixHash};
     use tvix_eval::generators::Gen;
     use tvix_eval::{generators::GenCo, ErrorKind, Value};
+    use tvix_eval::{NixContextElement, NixString};
 
     use tvix_castore::B3Digest;
 
@@ -242,7 +243,13 @@ mod import_builtins {
             Ok::<_, std::io::Error>(state.path_info_service.as_ref().put(path_info).await?)
         })?;
 
-        Ok(output_path.to_absolute_path().into())
+        // We need to attach context to the final output path.
+        let outpath = output_path.to_absolute_path();
+
+        Ok(
+            NixString::new_context_from(NixContextElement::Plain(outpath.clone()).into(), outpath)
+                .into(),
+        )
     }
 
     #[builtin("filterSource")]
@@ -256,7 +263,7 @@ mod import_builtins {
         let root_node = filtered_ingest(Rc::clone(&state), co, &p, Some(&filter)).await?;
         let name = tvix_store::import::path_to_name(&p)?;
 
-        Ok(state
+        let outpath = state
             .tokio_handle
             .block_on(async {
                 let (_, nar_sha256) = state
@@ -278,8 +285,12 @@ mod import_builtins {
                 path: Some(p.to_path_buf()),
                 error: err.into(),
             })?
-            .to_absolute_path()
-            .into())
+            .to_absolute_path();
+
+        Ok(
+            NixString::new_context_from(NixContextElement::Plain(outpath.clone()).into(), outpath)
+                .into(),
+        )
     }
 }