about summary refs log tree commit diff
path: root/tvix/glue/src/builtins/derivation.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-02-10T15·04+0100
committerflokli <flokli@flokli.de>2024-02-17T04·49+0000
commit58f474041ec18551b8e77b25f8c92e9347784f76 (patch)
treecd54710da27eda51f6a12013eb26300492e968d8 /tvix/glue/src/builtins/derivation.rs
parente7815945df66b2893e0c424169dde8ddbeb0efe3 (diff)
refactor(tvix/glue/KnownPaths): track Derivation struct too r/7534
We need to not only store a map from drv path to hash derivation modulo,
but also keep the original Derivation struct - because we'll use that
later to trigger builds.

Change-Id: I78e2e8431ab5ae853188866b797a79025200de98
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10790
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/glue/src/builtins/derivation.rs')
-rw-r--r--tvix/glue/src/builtins/derivation.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/tvix/glue/src/builtins/derivation.rs b/tvix/glue/src/builtins/derivation.rs
index efcacd8310cd..016eb9ba25f2 100644
--- a/tvix/glue/src/builtins/derivation.rs
+++ b/tvix/glue/src/builtins/derivation.rs
@@ -442,7 +442,10 @@ pub(crate) mod derivation_builtins {
         // Calculate the derivation_or_fod_hash for the current derivation.
         // This one is still intermediate (so not added to known_paths)
         let derivation_or_fod_hash_tmp = drv.derivation_or_fod_hash(|drv_path| {
-            known_paths.get_hash_derivation_modulo(&drv_path.to_owned())
+            known_paths
+                .get_hash_derivation_modulo(drv_path)
+                .unwrap_or_else(|| panic!("{} not found", drv_path))
+                .to_owned()
         });
 
         // Mutate the Derivation struct and set output paths
@@ -453,12 +456,8 @@ pub(crate) mod derivation_builtins {
             .calculate_derivation_path(name)
             .map_err(DerivationError::InvalidDerivation)?;
 
-        // recompute the hash derivation modulo and add to known_paths
-        let derivation_or_fod_hash_final = drv.derivation_or_fod_hash(|drv_path| {
-            known_paths.get_hash_derivation_modulo(&drv_path.to_owned())
-        });
-
-        known_paths.add_hash_derivation_modulo(drv_path.clone(), &derivation_or_fod_hash_final);
+        // TODO: avoid cloning
+        known_paths.add(drv_path.clone(), drv.clone());
 
         let mut new_attrs: Vec<(String, NixString)> = drv
             .outputs