about summary refs log tree commit diff
path: root/tvix/glue/src
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2023-12-30T02·21+0100
committerraitobezarius <tvl@lahfa.xyz>2024-01-14T03·37+0000
commit2750e1e640f5228afe1efcdb4deb4922887d0121 (patch)
tree1dccb67909d8a951ec49f5302ff1b5ad6e9fd11d /tvix/glue/src
parent37cc88897e0c6baa9835b49842e723f9e7006f5f (diff)
fix(tvix/eval): catchable-aware builtins r/7379
A bunch of operations in Tvix are not aware of catchable values
and does not propagate them.

In the meantime, as we wait for a better solution, we just offer this
commit for moving the needle.

Change-Id: Ic3f0e1550126b0847b597dfc1402c35e0eeef469
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10473
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/glue/src')
-rw-r--r--tvix/glue/src/builtins/derivation.rs27
1 files changed, 23 insertions, 4 deletions
diff --git a/tvix/glue/src/builtins/derivation.rs b/tvix/glue/src/builtins/derivation.rs
index 25b54805e6a4..728882af394d 100644
--- a/tvix/glue/src/builtins/derivation.rs
+++ b/tvix/glue/src/builtins/derivation.rs
@@ -132,6 +132,10 @@ pub(crate) mod derivation_builtins {
 
     #[builtin("placeholder")]
     async fn builtin_placeholder(co: GenCo, input: Value) -> Result<Value, ErrorKind> {
+        if input.is_catchable() {
+            return Ok(input);
+        }
+
         let placeholder = hash_placeholder(
             input
                 .to_str()
@@ -152,11 +156,18 @@ pub(crate) mod derivation_builtins {
         co: GenCo,
         input: Value,
     ) -> Result<Value, ErrorKind> {
+        if input.is_catchable() {
+            return Ok(input);
+        }
+
         let input = input.to_attrs()?;
-        let name = generators::request_force(&co, input.select_required("name")?.clone())
-            .await
-            .to_str()
-            .context("determining derivation name")?;
+        let name = generators::request_force(&co, input.select_required("name")?.clone()).await;
+
+        if name.is_catchable() {
+            return Ok(name);
+        }
+
+        let name = name.to_str().context("determining derivation name")?;
 
         if name.is_empty() {
             return Err(ErrorKind::Abort("derivation has empty name".to_string()));
@@ -480,6 +491,14 @@ pub(crate) mod derivation_builtins {
 
     #[builtin("toFile")]
     async fn builtin_to_file(co: GenCo, name: Value, content: Value) -> Result<Value, ErrorKind> {
+        if name.is_catchable() {
+            return Ok(name);
+        }
+
+        if content.is_catchable() {
+            return Ok(content);
+        }
+
         let name = name
             .to_str()
             .context("evaluating the `name` parameter of builtins.toFile")?;