about summary refs log tree commit diff
path: root/tvix/glue
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-03-14T11·50+0200
committerclbot <clbot@tvl.fyi>2024-03-14T16·52+0000
commit43c851bc841bccc65ffddab7205783c43f25417f (patch)
tree74249d4df9d5c82f5e12b345a62728bbeaed157f /tvix/glue
parent35f636b68482d8c84939b4707514a48416557bb4 (diff)
refactor(nix-compat/store_path): take [u8;32] for outer fingerprint r/7691
The outer fingerprint used for store path calculation is always a sha256
digest. This includes both input and output-addressed store paths.

We used a NixHash here, which can also represent other hash types, and
that had a bunch of annoyances:

 - Whenever we had the bytes, we had to wrap them in a NixHash::Sha256().
 - Things like AtermWriteable had to be implemented on NixHash,
   even though we then had an assertion it was only called in the
   NixHash::Sha256 case.

Change-Id: Ic895503d9b071800d2e52ae057666f44bd0ab9d6
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11142
Tested-by: BuildkiteCI
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: John Ericson <git@johnericson.me>
Reviewed-by: picnoir picnoir <picnoir@alternativebit.fr>
Diffstat (limited to 'tvix/glue')
-rw-r--r--tvix/glue/src/known_paths.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/tvix/glue/src/known_paths.rs b/tvix/glue/src/known_paths.rs
index 13f86fae0ea4..9cd9470fa949 100644
--- a/tvix/glue/src/known_paths.rs
+++ b/tvix/glue/src/known_paths.rs
@@ -8,7 +8,7 @@
 //! This data is required to find the derivation needed to actually trigger the
 //! build, if necessary.
 
-use nix_compat::{derivation::Derivation, nixhash::NixHash, store_path::StorePath};
+use nix_compat::{derivation::Derivation, store_path::StorePath};
 use std::collections::HashMap;
 
 /// Struct keeping track of all known Derivations in the current evaluation.
@@ -20,7 +20,7 @@ pub struct KnownPaths {
     ///
     /// Keys are derivation paths, values are a tuple of the "hash derivation
     /// modulo" and the Derivation struct itself.
-    derivations: HashMap<StorePath, (NixHash, Derivation)>,
+    derivations: HashMap<StorePath, ([u8; 32], Derivation)>,
 
     /// A map from output path to (one) drv path.
     /// Note that in the case of FODs, multiple drvs can produce the same output
@@ -30,7 +30,7 @@ pub struct KnownPaths {
 
 impl KnownPaths {
     /// Fetch the opaque "hash derivation modulo" for a given derivation path.
-    pub fn get_hash_derivation_modulo(&self, drv_path: &StorePath) -> Option<&NixHash> {
+    pub fn get_hash_derivation_modulo(&self, drv_path: &StorePath) -> Option<&[u8; 32]> {
         self.derivations
             .get(drv_path)
             .map(|(hash_derivation_modulo, _derivation)| hash_derivation_modulo)
@@ -83,7 +83,7 @@ impl KnownPaths {
         #[allow(unused_variables)] // assertions on this only compiled in debug builds
         let old = self
             .derivations
-            .insert(drv_path.to_owned(), (hash_derivation_modulo.clone(), drv));
+            .insert(drv_path.to_owned(), (hash_derivation_modulo, drv));
 
         #[cfg(debug_assertions)]
         {
@@ -99,7 +99,7 @@ impl KnownPaths {
 
 #[cfg(test)]
 mod tests {
-    use nix_compat::{derivation::Derivation, nixhash::NixHash, store_path::StorePath};
+    use nix_compat::{derivation::Derivation, store_path::StorePath};
 
     use super::KnownPaths;
     use hex_literal::hex;
@@ -165,9 +165,9 @@ mod tests {
 
         // It should be possible to get the hash derivation modulo.
         assert_eq!(
-            Some(&NixHash::Sha256(hex!(
+            Some(&hex!(
                 "c79aebd0ce3269393d4a1fde2cbd1d975d879b40f0bf40a48f550edc107fd5df"
-            ))),
+            )),
             known_paths.get_hash_derivation_modulo(&BAR_DRV_PATH.clone())
         );
 
@@ -180,9 +180,9 @@ mod tests {
             known_paths.get_drv_by_drvpath(&FOO_DRV_PATH)
         );
         assert_eq!(
-            Some(&NixHash::Sha256(hex!(
+            Some(&hex!(
                 "af030d36d63d3d7f56a71adaba26b36f5fa1f9847da5eed953ed62e18192762f"
-            ))),
+            )),
             known_paths.get_hash_derivation_modulo(&FOO_DRV_PATH.clone())
         );