diff options
author | Florian Klink <flokli@flokli.de> | 2023-01-26T13·42+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2023-01-30T11·46+0000 |
commit | 8ec8d03175e5e658600543dd0ba895f3f40e51e6 (patch) | |
tree | 4393e5d562556acb60ef604f5787658d1dbaa47d /tvix/derivation/src/derivation.rs | |
parent | 85e563c554b338dc73770ebeffc7fdd642e3f627 (diff) |
fix(tvix/store/nixbase32): fix encoder/decoder r/5781
Replace our data_encoding usage with the implementation taken from https://github.com/nix-community/go-nix/tree/master/pkg/nixbase32 Also uncomment some of the unit tests, and add a regression test for a NIXBASE32.encode with a 32 bytes sequence. The previous implementation of NIXBASE32.encode is wrong in that case: ``` ❯ nix hash to-base32 sha256-s6JN6XqP28g1uYMxaVAQMLiXcDG8tUs7OsE3QPhGqzA= 0c5b8vw40dy178xlpddw65q9gf1h2186jcc3p4swinwggbllv8mk ❯ echo -n s6JN6XqP28g1uYMxaVAQMLiXcDG8tUs7OsE3QPhGqzA= | base64 -d | hexdump -C 00000000 b3 a2 4d e9 7a 8f db c8 35 b9 83 31 69 50 10 30 |..M.z...5..1iP.0| 00000010 b8 97 70 31 bc b5 4b 3b 3a c1 37 40 f8 46 ab 30 |..p1..K;:.7@.F.0| 00000020 ``` Change-Id: I0468b62bbbab390f8d7d3812e657e5d59dceed59 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7934 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: Adam Joseph <adam@westernsemico.com> Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/derivation/src/derivation.rs')
-rw-r--r-- | tvix/derivation/src/derivation.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tvix/derivation/src/derivation.rs b/tvix/derivation/src/derivation.rs index 45fcfb6b9f4b..390024da33ee 100644 --- a/tvix/derivation/src/derivation.rs +++ b/tvix/derivation/src/derivation.rs @@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::collections::BTreeSet; use std::{collections::BTreeMap, fmt, fmt::Write}; -use tvix_store::nixbase32::NIXBASE32; +use tvix_store::nixbase32; use tvix_store::store_path::{StorePath, STORE_DIR}; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] @@ -64,9 +64,9 @@ fn build_store_path( }; let compressed = compress_hash(&digest, 20); if is_derivation { - StorePath::from_string(format!("{}-{}.drv", NIXBASE32.encode(&compressed), name).as_str()) + StorePath::from_string(format!("{}-{}.drv", nixbase32::encode(&compressed), name).as_str()) } else { - StorePath::from_string(format!("{}-{}", NIXBASE32.encode(&compressed), name,).as_str()) + StorePath::from_string(format!("{}-{}", nixbase32::encode(&compressed), name,).as_str()) } .map_err(|_e| DerivationError::InvalidOutputName(name.to_string())) // Constructing the StorePath can only fail if the passed output name was |