refactor(tvix/nix-compat): rename NixHashWithMode -> CAHash
This specific struct is only used to represent content-addressed paths (in case a Derivation has a fixed-output hash, for example). Rename `Output`'s `hash_with_mode` to `ca_hash`. We now also include `CAHash::Text`, and update the `validate` function of the `Output` struct to reject text hashes there. This allows cleaning up the various output path calculation functions inside nix-compat/src/store_path/utils.rs, as they can now match on the type. `make_type` is renamed to `make_references_string`, `build_regular_ca_path` is renamed to `build_ca_path`, and `build_text_path` has a disclaimer added, because you might not actually want to use it. Change-Id: I674d065f2ed5c804012ddfed56e161ac49d23931 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9814 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
833957b374
commit
34fc4637eb
10 changed files with 222 additions and 209 deletions
|
|
@ -4,7 +4,7 @@
|
|||
//! [ATerm]: http://program-transformation.org/Tools/ATermFormat.html
|
||||
|
||||
use crate::aterm::escape_bytes;
|
||||
use crate::derivation::output::Output;
|
||||
use crate::derivation::{ca_kind_prefix, output::Output};
|
||||
use bstr::BString;
|
||||
use std::{
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
|
|
@ -79,14 +79,10 @@ pub fn write_outputs(
|
|||
|
||||
let mut elements: Vec<&str> = vec![output_name, &output.path];
|
||||
|
||||
let (mode_and_algo, digest) = match &output.hash_with_mode {
|
||||
Some(crate::nixhash::NixHashWithMode::Flat(h)) => (
|
||||
h.algo().to_string(),
|
||||
data_encoding::HEXLOWER.encode(h.digest_as_bytes()),
|
||||
),
|
||||
Some(crate::nixhash::NixHashWithMode::Recursive(h)) => (
|
||||
format!("r:{}", h.algo()),
|
||||
data_encoding::HEXLOWER.encode(h.digest_as_bytes()),
|
||||
let (mode_and_algo, digest) = match &output.ca_hash {
|
||||
Some(ca_hash) => (
|
||||
format!("{}{}", ca_kind_prefix(ca_hash), ca_hash.digest().algo()),
|
||||
data_encoding::HEXLOWER.encode(ca_hash.digest().digest_as_bytes()),
|
||||
),
|
||||
None => ("".to_string(), "".to_string()),
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue