From 4d6137964b53f77f1c9ef1765aa61e8e414bdeaf Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 27 Dec 2023 17:56:28 +0100 Subject: feat(tvix/build): don't force outputs to be in store_dir 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 Autosubmit: flokli --- tvix/glue/src/tvix_build.rs | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'tvix/glue') diff --git a/tvix/glue/src/tvix_build.rs b/tvix/glue/src/tvix_build.rs index a0ebf49e12..b647c7d405 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 = derivation + // produce output_paths, which is the absolute path of each output (sorted) + let mut output_paths: Vec = 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 ); -- cgit 1.4.1