feat(tvix/glue/store_io): have KnownPaths track fetches too
Have fetcher builtins call queue_fetch() whenever they don't need to fetch something immediately, and teach TvixStoreIO::store_path_to_node on how to look up (and call ingest_and persist on our Fetcher). Change-Id: Id4bd9d639fac9e4bee20c0b1c584148740b15c2f Reviewed-on: https://cl.tvl.fyi/c/depot/+/11501 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
This commit is contained in:
parent
091de12a9a
commit
30950833c9
5 changed files with 146 additions and 18 deletions
|
|
@ -475,7 +475,7 @@ pub(crate) mod derivation_builtins {
|
|||
.map_err(DerivationError::InvalidDerivation)?;
|
||||
|
||||
// TODO: avoid cloning
|
||||
known_paths.add(drv_path.clone(), drv.clone());
|
||||
known_paths.add_derivation(drv_path.clone(), drv.clone());
|
||||
|
||||
let mut new_attrs: Vec<(String, NixString)> = drv
|
||||
.outputs
|
||||
|
|
|
|||
|
|
@ -87,11 +87,20 @@ pub(crate) mod fetcher_builtins {
|
|||
.map_err(|e| ErrorKind::TvixError(Rc::new(e)))?
|
||||
{
|
||||
Some(store_path) => {
|
||||
let path = store_path.to_absolute_path().into();
|
||||
// TODO: add fetch to fetcher
|
||||
drop(fetch);
|
||||
// Move the fetch to KnownPaths, so it can be actually fetched later.
|
||||
let sp = state
|
||||
.known_paths
|
||||
.borrow_mut()
|
||||
.add_fetch(fetch, &name)
|
||||
.expect("Tvix bug: should only fail if the store path cannot be calculated");
|
||||
|
||||
Ok(Value::Path(Box::new(path)))
|
||||
debug_assert_eq!(
|
||||
sp, store_path,
|
||||
"calculated store path by KnownPaths should match"
|
||||
);
|
||||
|
||||
// Emit the calculated Store Path.
|
||||
Ok(Value::Path(Box::new(store_path.to_absolute_path().into())))
|
||||
}
|
||||
None => {
|
||||
// If we don't have enough info, do the fetch now.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue