diff options
author | Florian Klink <flokli@flokli.de> | 2023-11-19T17·50+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-11-22T17·54+0000 |
commit | ef8a8af0bfa5963a4a19023acb2c94c3bc61f4d6 (patch) | |
tree | 1ff54b83215b21006008e6fd6371457603e0541d /tvix/nix-compat/src/store_path/utils.rs | |
parent | a8d48d4d9c2c4f1f4c97007271c1bfc36d989c74 (diff) |
refactor(tvix/nix-compat): cleanup parse_{ca,hash} and fmt structs r/7045
These were used to format to and parse from strings. Move this to the CAHash and NixHash structs directly, and be explicit in the name about which encoding for digests is used. For output path calculation, nix encodes the nixpaths in hex, but for writing out NARInfos, it's using nixbase32. Change-Id: Ia585a76a3811b2609e7ce259fda66a29403b7e07 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10079 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nix-compat/src/store_path/utils.rs')
-rw-r--r-- | tvix/nix-compat/src/store_path/utils.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/tvix/nix-compat/src/store_path/utils.rs b/tvix/nix-compat/src/store_path/utils.rs index a227056edc21..dd32135135db 100644 --- a/tvix/nix-compat/src/store_path/utils.rs +++ b/tvix/nix-compat/src/store_path/utils.rs @@ -93,7 +93,7 @@ pub fn build_ca_path<B: AsRef<[u8]>, S: AsRef<str>, I: IntoIterator<Item = S>>( NixHash::Sha256( Sha256::new_with_prefix(format!( "fixed:out:r:{}:", - hash.to_nix_hash_string() + hash.to_nix_hex_string() )) .finalize() .into(), @@ -115,12 +115,9 @@ pub fn build_ca_path<B: AsRef<[u8]>, S: AsRef<str>, I: IntoIterator<Item = S>>( "output:out", &{ NixHash::Sha256( - Sha256::new_with_prefix(format!( - "fixed:out:{}:", - hash.to_nix_hash_string() - )) - .finalize() - .into(), + Sha256::new_with_prefix(format!("fixed:out:{}:", hash.to_nix_hex_string())) + .finalize() + .into(), ) }, name, @@ -170,7 +167,7 @@ fn build_store_path_from_fingerprint_parts<B: AsRef<[u8]>>( let digest = compress_hash(&{ let mut h = Sha256::new(); - write!(h, "{ty}:{}:{STORE_DIR}:{name}", hash.to_nix_hash_string()).unwrap(); + write!(h, "{ty}:{}:{STORE_DIR}:{name}", hash.to_nix_hex_string()).unwrap(); h.finalize() }); |