about summary refs log tree commit diff
path: root/tvix/glue/src/builtins/derivation.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-04-08T21·30+0300
committerclbot <clbot@tvl.fyi>2024-04-08T21·43+0000
commit84ad8a0bbd19f1058e0ab2feac07f9d44f275be3 (patch)
tree2997dbcf2928e2bb8b390e9f3ed1d2700dd92060 /tvix/glue/src/builtins/derivation.rs
parentf1496f5722820eeae63edf34daee1c3a95a21df0 (diff)
fix(tvix/glue/derivation): fix __structuredAttrs "outputs" handling r/7880
In case structured attrs is enabled, rather than adding a
space-separated list to the "outputs" environment variable, a "proper"
list is added to the JSON itself, at the "outputs" key.

Fixes b/395.

Reported-By: Alyssa Ross <hi@alyssa.is>
Change-Id: I2834ede9cfcf49d5e81e1056bf8f9bb9b65ddad8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11386
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/glue/src/builtins/derivation.rs')
-rw-r--r--tvix/glue/src/builtins/derivation.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/tvix/glue/src/builtins/derivation.rs b/tvix/glue/src/builtins/derivation.rs
index 54bc7878bdd4..078cb0e1ffd1 100644
--- a/tvix/glue/src/builtins/derivation.rs
+++ b/tvix/glue/src/builtins/derivation.rs
@@ -316,8 +316,16 @@ pub(crate) mod derivation_builtins {
                         output_names.push(output_name.to_str()?.to_owned());
                     }
 
-                    // Add drv.environment[outputs] unconditionally.
-                    insert_env(&mut drv, arg_name, output_names.join(" ").into())?;
+                    match structured_attrs.as_mut() {
+                        // add outputs to the json itself (as a list of strings)
+                        Some(structured_attrs) => {
+                            structured_attrs.insert(arg_name.into(), output_names.into());
+                        }
+                        // add drv.environment["outputs"] as a space-separated list
+                        None => {
+                            insert_env(&mut drv, arg_name, output_names.join(" ").into())?;
+                        }
+                    }
                     // drv.environment[$output_name] is added after the loop,
                     // with whatever is in drv.outputs[$output_name].
                 }