diff options
Diffstat (limited to 'tvix/nix-compat/src')
-rw-r--r-- | tvix/nix-compat/src/derivation/mod.rs | 13 | ||||
-rw-r--r-- | tvix/nix-compat/src/derivation/utils.rs | 7 |
2 files changed, 14 insertions, 6 deletions
diff --git a/tvix/nix-compat/src/derivation/mod.rs b/tvix/nix-compat/src/derivation/mod.rs index f500161f9181..d348b0d716b9 100644 --- a/tvix/nix-compat/src/derivation/mod.rs +++ b/tvix/nix-compat/src/derivation/mod.rs @@ -1,4 +1,7 @@ -use crate::store_path::{self, StorePath}; +use crate::{ + nixhash::NixHash, + store_path::{self, StorePath}, +}; use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::collections::{BTreeMap, BTreeSet}; @@ -100,7 +103,7 @@ impl Derivation { /// This is: `text:`, /// all d.InputDerivations and d.InputSources (sorted, separated by a `:`), /// a `:`, - /// a `sha256:`, followed by the sha256 digest of the ATerm representation (hex-encoded) + /// the nix string representation of the sha256 sum of the ATerm representation /// a `:`, /// the storeDir, followed by a `:`, /// the name of a derivation, @@ -135,9 +138,11 @@ impl Derivation { derivation_hasher.finalize() }; + let h = NixHash::new(crate::nixhash::HashAlgo::Sha256, aterm_digest.to_vec()); + s.push_str(&format!( - "sha256:{:x}:{}:{}.drv", - aterm_digest, + "{}:{}:{}.drv", + h.to_nix_hash_string(), store_path::STORE_DIR, name, )); diff --git a/tvix/nix-compat/src/derivation/utils.rs b/tvix/nix-compat/src/derivation/utils.rs index 77ac94b42462..cbb5d02a2180 100644 --- a/tvix/nix-compat/src/derivation/utils.rs +++ b/tvix/nix-compat/src/derivation/utils.rs @@ -1,5 +1,6 @@ use crate::derivation::DerivationError; use crate::nixbase32; +use crate::nixhash::NixHash; use crate::store_path::{self, StorePath}; use sha2::{Digest, Sha256}; @@ -67,9 +68,11 @@ pub fn path_with_references<S: AsRef<str>, I: IntoIterator<Item = S>, C: AsRef<[ hasher.finalize() }; + let h = NixHash::new(crate::nixhash::HashAlgo::Sha256, content_digest.to_vec()); + s.push_str(&format!( - ":sha256:{:x}:{}:{}", - content_digest, + ":{}:{}:{}", + h.to_nix_hash_string(), store_path::STORE_DIR, name )); |