feat(tvix/nix-compat): input_derivations with StorePaths
...in `Derivation`. This is more type-safe and should consume less memory. This also removes some allocations in the potentially hot path of output hash calculation. https: //b.tvl.fyi/issues/264 Change-Id: I6ad7d3cb868dc9f750894d449a6065608ef06e8c Reviewed-on: https://cl.tvl.fyi/c/depot/+/10957 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de> Autosubmit: Peter Kolloch <info@eigenvalue.net> Reviewed-by: Peter Kolloch <info@eigenvalue.net>
This commit is contained in:
parent
a44a8985cc
commit
c06fb01b3b
9 changed files with 138 additions and 73 deletions
|
|
@ -4,6 +4,7 @@ use crate::tvix_store_io::TvixStoreIO;
|
|||
use bstr::BString;
|
||||
use nix_compat::derivation::{Derivation, Output};
|
||||
use nix_compat::nixhash;
|
||||
use nix_compat::store_path::StorePath;
|
||||
use std::collections::{btree_map, BTreeSet};
|
||||
use std::rc::Rc;
|
||||
use tvix_eval::builtin_macros::builtins;
|
||||
|
|
@ -26,7 +27,23 @@ fn populate_inputs(drv: &mut Derivation, full_context: NixContext) {
|
|||
drv.input_sources.insert(source.clone());
|
||||
}
|
||||
|
||||
NixContextElement::Single { name, derivation } => {
|
||||
NixContextElement::Single {
|
||||
name,
|
||||
derivation: derivation_str,
|
||||
} => {
|
||||
// TODO: b/264
|
||||
// We assume derivations to be passed validated, so ignoring rest
|
||||
// and expecting parsing is ok.
|
||||
let (derivation, _rest) =
|
||||
StorePath::from_absolute_path_full(derivation_str).expect("valid store path");
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
assert!(
|
||||
_rest.iter().next().is_none(),
|
||||
"Extra path not empty for {}",
|
||||
derivation_str
|
||||
);
|
||||
|
||||
match drv.input_derivations.entry(derivation.clone()) {
|
||||
btree_map::Entry::Vacant(entry) => {
|
||||
entry.insert(BTreeSet::from([name.clone()]));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue