From 38e8c2e95931673deb7cb939a05ac9bdaf305340 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 3 Feb 2023 00:20:02 +0300 Subject: fix(tvix/cli): keep tracking full paths in known_paths We need to distinguish explicitly between the paths used for the scanner, and the paths that populate the derivation inputs. The full paths must be accessible from the result of the refscanner to populate drv fields correctly. This was previously hidden by debug changes that masked actual IO operations with no-ops. Change-Id: I037af6e6bbe2b573034d695f8779bee1b56bc125 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8022 Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/cli/src/derivation.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'tvix/cli/src/derivation.rs') diff --git a/tvix/cli/src/derivation.rs b/tvix/cli/src/derivation.rs index 6af3d24a24..88c5e52296 100644 --- a/tvix/cli/src/derivation.rs +++ b/tvix/cli/src/derivation.rs @@ -8,7 +8,7 @@ use tvix_eval::builtin_macros::builtins; use tvix_eval::{AddContext, CoercionKind, ErrorKind, NixAttrs, NixList, Value, VM}; use crate::errors::Error; -use crate::known_paths::{KnownPaths, PathType}; +use crate::known_paths::{KnownPaths, PathKind, PathName}; // Constants used for strangely named fields in derivation inputs. const STRUCTURED_ATTRS: &str = "__structuredAttrs"; @@ -41,18 +41,19 @@ fn populate_outputs(vm: &mut VM, drv: &mut Derivation, outputs: NixList) -> Resu /// Populate the inputs of a derivation from the build references /// found when scanning the derivation's parameters. -fn populate_inputs>( +fn populate_inputs>( drv: &mut Derivation, known_paths: &KnownPaths, references: I, ) { for reference in references.into_iter() { - match &known_paths[&reference] { - PathType::Plain => { - drv.input_sources.insert(reference.to_string()); + let reference = &known_paths[&reference]; + match &reference.kind { + PathKind::Plain => { + drv.input_sources.insert(reference.path.clone()); } - PathType::Output { name, derivation } => { + PathKind::Output { name, derivation } => { match drv.input_derivations.entry(derivation.clone()) { btree_map::Entry::Vacant(entry) => { entry.insert(BTreeSet::from([name.clone()])); @@ -64,8 +65,8 @@ fn populate_inputs>( } } - PathType::Derivation { output_names } => { - match drv.input_derivations.entry(reference.to_string()) { + PathKind::Derivation { output_names } => { + match drv.input_derivations.entry(reference.path.clone()) { btree_map::Entry::Vacant(entry) => { entry.insert(output_names.clone()); } @@ -389,7 +390,14 @@ mod derivation_builtins { let mut refscan = state.borrow().reference_scanner(); refscan.scan_str(content.as_str()); - let refs = refscan.finalise(); + let refs = { + let paths = state.borrow(); + refscan + .finalise() + .into_iter() + .map(|path| paths[&path].path.to_string()) + .collect::>() + }; // TODO: fail on derivation references (only "plain" is allowed here) @@ -491,7 +499,7 @@ mod tests { "/nix/store/aqffiyqx602lbam7n1zsaz3yrh6v08pc-bar.drv", ); - let inputs: Vec = vec![ + let inputs = vec![ "/nix/store/fn7zvafq26f0c8b17brs7s95s10ibfzs-foo".into(), "/nix/store/aqffiyqx602lbam7n1zsaz3yrh6v08pc-bar.drv".into(), "/nix/store/zvpskvjwi72fjxg0vzq822sfvq20mq4l-bar".into(), -- cgit 1.4.1