about summary refs log tree commit diff
path: root/tvix/nix-compat
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/nix-compat')
-rw-r--r--tvix/nix-compat/src/derivation/validate.rs2
-rw-r--r--tvix/nix-compat/src/nixhash/ca_hash.rs12
-rw-r--r--tvix/nix-compat/src/store_path/utils.rs9
3 files changed, 9 insertions, 14 deletions
diff --git a/tvix/nix-compat/src/derivation/validate.rs b/tvix/nix-compat/src/derivation/validate.rs
index 3474dcb5dbbb..37ddf9017138 100644
--- a/tvix/nix-compat/src/derivation/validate.rs
+++ b/tvix/nix-compat/src/derivation/validate.rs
@@ -141,7 +141,7 @@ mod test {
             "out".to_string(),
             Output {
                 path: "".to_string(),
-                ca_hash: Some(CAHash::Text(Box::new([0; 32]))), // This is disallowed
+                ca_hash: Some(CAHash::Text([0; 32])), // This is disallowed
             },
         );
 
diff --git a/tvix/nix-compat/src/nixhash/ca_hash.rs b/tvix/nix-compat/src/nixhash/ca_hash.rs
index 5d9ae3f3a861..93ef52cc63ab 100644
--- a/tvix/nix-compat/src/nixhash/ca_hash.rs
+++ b/tvix/nix-compat/src/nixhash/ca_hash.rs
@@ -19,17 +19,17 @@ use super::from_algo_and_digest;
 ///  - "digest". The digest itself.
 #[derive(Clone, Debug, Eq, PartialEq)]
 pub enum CAHash {
-    Flat(NixHash),       // "fixed flat"
-    Nar(NixHash),        // "fixed recursive"
-    Text(Box<[u8; 32]>), // "text", only supports sha256
+    Flat(NixHash),  // "fixed flat"
+    Nar(NixHash),   // "fixed recursive"
+    Text([u8; 32]), // "text", only supports sha256
 }
 
 impl CAHash {
     pub fn digest(&self) -> Cow<NixHash> {
-        match self {
-            CAHash::Nar(ref digest) => Cow::Borrowed(digest),
-            CAHash::Text(ref digest) => Cow::Owned(NixHash::Sha256(*digest.clone())),
+        match *self {
             CAHash::Flat(ref digest) => Cow::Borrowed(digest),
+            CAHash::Nar(ref digest) => Cow::Borrowed(digest),
+            CAHash::Text(digest) => Cow::Owned(NixHash::Sha256(digest)),
         }
     }
 
diff --git a/tvix/nix-compat/src/store_path/utils.rs b/tvix/nix-compat/src/store_path/utils.rs
index b625abdfd0b9..375882795c31 100644
--- a/tvix/nix-compat/src/store_path/utils.rs
+++ b/tvix/nix-compat/src/store_path/utils.rs
@@ -50,12 +50,7 @@ pub fn build_text_path<S: AsRef<str>, I: IntoIterator<Item = S>, C: AsRef<[u8]>>
     // produce the sha256 digest of the contents
     let content_digest = Sha256::new_with_prefix(content).finalize().into();
 
-    build_ca_path(
-        name,
-        &CAHash::Text(Box::new(content_digest)),
-        references,
-        false,
-    )
+    build_ca_path(name, &CAHash::Text(content_digest), references, false)
 }
 
 /// This builds a store path from a [CAHash] and a list of references.
@@ -72,7 +67,7 @@ pub fn build_ca_path<B: AsRef<[u8]>, S: AsRef<str>, I: IntoIterator<Item = S>>(
             }
             build_store_path_from_fingerprint_parts(
                 &make_references_string("text", references, false),
-                &NixHash::Sha256(*digest.to_owned()),
+                &NixHash::Sha256(*digest),
                 name,
             )
             .map_err(BuildStorePathError::InvalidStorePath)