diff options
author | Florian Klink <flokli@flokli.de> | 2023-12-27T16·56+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-12-29T22·14+0000 |
commit | 4d6137964b53f77f1c9ef1765aa61e8e414bdeaf (patch) | |
tree | 771c311becb5c59144c9d61515c65c4183e39d62 /tvix/glue | |
parent | 3e63d7be42c57f9724dcf5ff2ff3121ceb428f00 (diff) |
feat(tvix/build): don't force outputs to be in store_dir r/7283
There's no need to require builds to also put their outputs in store_dir. So rename store_dir to inputs_dir and make outputs consume paths, not basenames. Also document the possibility for builds to write to inputs_dir. Let's see if we want to make this a constraint later. Change-Id: Ib4df20afcdde2d771c269c422f04c7e95587cd0f Reviewed-on: https://cl.tvl.fyi/c/depot/+/10447 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/glue')
-rw-r--r-- | tvix/glue/src/tvix_build.rs | 39 |
1 files changed, 16 insertions, 23 deletions
diff --git a/tvix/glue/src/tvix_build.rs b/tvix/glue/src/tvix_build.rs index a0ebf49e1229..b647c7d40545 100644 --- a/tvix/glue/src/tvix_build.rs +++ b/tvix/glue/src/tvix_build.rs @@ -52,22 +52,15 @@ where command_args.push(derivation.builder.clone()); command_args.extend_from_slice(&derivation.arguments); - // produce output_paths, which is the basename of each output (sorted) - // since Derivation is validated, we know output paths can be parsed. - // TODO: b/264 will remove the need to parse them here - let mut outputs: Vec<String> = derivation + // produce output_paths, which is the absolute path of each output (sorted) + let mut output_paths: Vec<String> = derivation .outputs .values() - .map(|output| { - let output_storepath = StorePathRef::from_absolute_path(output.path.as_bytes()) - .expect("invalid output storepath"); - - output_storepath.to_string() - }) + .map(|e| e.path[1..].to_owned()) .collect(); // Sort the outputs. We can use sort_unstable, as these are unique strings. - outputs.sort_unstable(); + output_paths.sort_unstable(); // Produce environment_vars. We use a BTreeMap while producing them, so the // resulting Vec is sorted by key. @@ -151,13 +144,13 @@ where BuildRequest { command_args, - outputs, + outputs: output_paths, environment_vars, inputs, + inputs_dir: nix_compat::store_path::STORE_DIR.into(), constraints, working_dir: "build".into(), - scratch_paths: vec!["build".into()], - store_dir: nix_compat::store_path::STORE_DIR.into(), + scratch_paths: vec!["build".into(), "nix/store".into()], } } @@ -245,10 +238,11 @@ mod test { assert_eq!( BuildRequest { - command_args: vec![":".to_string()], - outputs: vec!["fhaj6gmwns62s6ypkcldbaj2ybvkhx3p-foo".to_string()], + command_args: vec![":".into()], + outputs: vec!["nix/store/fhaj6gmwns62s6ypkcldbaj2ybvkhx3p-foo".into()], environment_vars: expected_environment_vars, inputs: vec![INPUT_NODE_FOO.clone()], + inputs_dir: nix_compat::store_path::STORE_DIR.into(), constraints: Some(BuildConstraints { system: derivation.system.clone(), min_memory: 0, @@ -256,9 +250,8 @@ mod test { available_ro_paths: vec![], provide_bin_sh: true, }), - working_dir: "build".to_string(), - scratch_paths: vec!["build".to_string()], - store_dir: nix_compat::store_path::STORE_DIR.to_string(), + working_dir: "build".into(), + scratch_paths: vec!["build".into(), "nix/store".into()], }, build_request ); @@ -314,9 +307,10 @@ mod test { assert_eq!( BuildRequest { command_args: vec![":".to_string()], - outputs: vec!["4q0pg5zpfmznxscq3avycvf9xdvx50n3-bar".to_string()], + outputs: vec!["nix/store/4q0pg5zpfmznxscq3avycvf9xdvx50n3-bar".into()], environment_vars: expected_environment_vars, inputs: vec![], + inputs_dir: nix_compat::store_path::STORE_DIR.into(), constraints: Some(BuildConstraints { system: derivation.system.clone(), min_memory: 0, @@ -324,9 +318,8 @@ mod test { available_ro_paths: vec![], provide_bin_sh: true, }), - working_dir: "build".to_string(), - scratch_paths: vec!["build".to_string()], - store_dir: nix_compat::store_path::STORE_DIR.to_string(), + working_dir: "build".into(), + scratch_paths: vec!["build".into(), "nix/store".into()], }, build_request ); |