From 2750e1e640f5228afe1efcdb4deb4922887d0121 Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Sat, 30 Dec 2023 03:21:45 +0100 Subject: fix(tvix/eval): catchable-aware builtins 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 --- tvix/glue/src/builtins/derivation.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'tvix/glue/src/builtins') 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 { + 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 { + 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 { + 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")?; -- cgit 1.4.1