diff options
author | Florian Klink <flokli@flokli.de> | 2023-03-04T02·25+0100 |
---|---|---|
committer | tazjin <tazjin@tvl.su> | 2023-03-04T12·26+0000 |
commit | 1f9b5822391fa63b83f4224ba43ed404ded6dae8 (patch) | |
tree | 11e9a8006e3792e253409b778bde56713588edb4 /tvix/nix-compat/src/derivation/mod.rs | |
parent | c2a681eaff09777011e6ea892411f6ac261caea7 (diff) |
feat(tvix/nix-compat/derivation): make use of NixPath in some places r/5882
Some of these strings are actually just the nix hash representation of the hash calculated earlier. There's another one passed around via calculate_drv_replacement_str, but that's left for a followup. Change-Id: Id99a2a926a980d679eb49c34ee6a36bf224699b0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8218 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat/src/derivation/mod.rs')
-rw-r--r-- | tvix/nix-compat/src/derivation/mod.rs | 13 |
1 files changed, 9 insertions, 4 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, )); |