refactor(tvix/glue): create environment_vars Vec at the end

Prevent code in this function from accessing the Vec, realize it only
when returning the BuildRequest struct.

Change-Id: I385c1adca552c9cb261cd70c5ca3ec45f0d7a9c3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10521
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2024-01-02 14:23:39 +02:00 committed by clbot
parent 7f030fe265
commit 9abe735061

View file

@ -83,13 +83,6 @@ where
.map(|(k, v)| (k.clone(), Bytes::from(v.to_vec()))),
);
// Turn this into a sorted-by-key Vec<EnvVar>.
let environment_vars = Vec::from_iter(
environment_vars
.into_iter()
.map(|(k, v)| EnvVar { key: k, value: v }),
);
// Produce inputs. As we refer to the contents here, not just plain store path strings,
// we need to perform lookups.
// FUTUREWORK: should we also model input_derivations and input_sources with StorePath?
@ -145,7 +138,13 @@ where
BuildRequest {
command_args,
outputs: output_paths,
environment_vars,
// Turn this into a sorted-by-key Vec<EnvVar>.
environment_vars: Vec::from_iter(
environment_vars
.into_iter()
.map(|(key, value)| EnvVar { key, value }),
),
inputs,
inputs_dir: nix_compat::store_path::STORE_DIR.into(),
constraints,