From 2a01c40e7726f3e4a3dcbbb71dcce85512ae670b Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 3 Jun 2025 22:34:55 +0300 Subject: [PATCH] fix(nix-compat/nixhash): fix from_nix_nixbase32_str fn name This was decoding nixbase32, not hex. Its only consumer (in ca_hash.rs) was right in its docstring about how it behaves, only was calling the wrongly-named function. Change-Id: I97ea273706ba818d16a61b1574989db800f78ead Reviewed-on: https://cl.snix.dev/c/snix/+/30553 Reviewed-by: Ilan Joselevich Tested-by: besadii Autosubmit: Florian Klink --- snix/nix-compat/src/nixhash/ca_hash.rs | 4 ++-- snix/nix-compat/src/nixhash/mod.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/snix/nix-compat/src/nixhash/ca_hash.rs b/snix/nix-compat/src/nixhash/ca_hash.rs index e6cbaf5b7..1d4d65e4e 100644 --- a/snix/nix-compat/src/nixhash/ca_hash.rs +++ b/snix/nix-compat/src/nixhash/ca_hash.rs @@ -85,9 +85,9 @@ impl CAHash { } "fixed" => { if let Some(s) = s.strip_prefix("r:") { - NixHash::from_nix_hex_str(s).map(CAHash::Nar) + NixHash::from_nix_nixbase32_str(s).map(CAHash::Nar) } else { - NixHash::from_nix_hex_str(s).map(CAHash::Flat) + NixHash::from_nix_nixbase32_str(s).map(CAHash::Flat) } } _ => None, diff --git a/snix/nix-compat/src/nixhash/mod.rs b/snix/nix-compat/src/nixhash/mod.rs index 9cb6f6605..07720e7ff 100644 --- a/snix/nix-compat/src/nixhash/mod.rs +++ b/snix/nix-compat/src/nixhash/mod.rs @@ -73,9 +73,9 @@ impl NixHash { } } - /// Constructs a [NixHash] from the Nix default hash format, - /// the inverse of [Self::to_nix_hex_string]. - pub fn from_nix_hex_str(s: &str) -> Option { + /// Constructs a new [NixHash] from the Nix default hash format, + /// the inverse of [Self::to_nix_nixbase32_string]. + pub fn from_nix_nixbase32_str(s: &str) -> Option { let (tag, digest) = s.split_once(':')?; (match tag { @@ -98,7 +98,7 @@ impl NixHash { /// Formats a [NixHash] in the format that's used inside CAHash, /// which is the algo, followed by a colon, then the nixbase32-encoded digest. - pub(crate) fn to_nix_nixbase32_string(&self) -> String { + pub fn to_nix_nixbase32_string(&self) -> String { format!( "{}:{}", self.algo(),