refactor(tvix/nix-compat): -derivation::Hash, +NixHash
This stops using our own custom Hash structure, which was mostly only used because we had to parse the JSON representation somehow. Since cl/8217, there's a `NixHash` struct, which is better suited to hold this data. Converting the format requires a bit of serde labor though, but that only really matters when interacting with JSON representations (which we mostly don't). Change-Id: Idc5ee511e36e6726c71f66face8300a441b0bf4c Reviewed-on: https://cl.tvl.fyi/c/depot/+/8304 Autosubmit: flokli <flokli@flokli.de> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
e82385dbe5
commit
b55d1f97ce
8 changed files with 201 additions and 87 deletions
|
|
@ -58,16 +58,22 @@ pub fn write_outputs(
|
|||
|
||||
let mut elements: Vec<&str> = vec![output_name, &output.path];
|
||||
|
||||
match &output.hash {
|
||||
Some(hash) => {
|
||||
elements.push(&hash.algo);
|
||||
elements.push(&hash.digest);
|
||||
}
|
||||
None => {
|
||||
elements.push("");
|
||||
elements.push("");
|
||||
}
|
||||
}
|
||||
let (e2, e3) = match &output.hash_with_mode {
|
||||
Some(hash) => match hash {
|
||||
crate::nixhash::NixHashWithMode::Flat(h) => (
|
||||
h.algo.to_string(),
|
||||
data_encoding::HEXLOWER.encode(&h.digest),
|
||||
),
|
||||
crate::nixhash::NixHashWithMode::Recursive(h) => (
|
||||
format!("r:{}", h.algo),
|
||||
data_encoding::HEXLOWER.encode(&h.digest),
|
||||
),
|
||||
},
|
||||
None => ("".to_string(), "".to_string()),
|
||||
};
|
||||
|
||||
elements.push(&e2);
|
||||
elements.push(&e3);
|
||||
|
||||
write_array_elements(
|
||||
writer,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue