refactor(tvix/cli): use nixhash module for output hash calculation
This covers all the weird corner cases. Change-Id: I85637e82e8929828064ab562dc8a1c8bf161fffa Reviewed-on: https://cl.tvl.fyi/c/depot/+/7991 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
parent
265dd36b98
commit
99d5cf822a
2 changed files with 20 additions and 73 deletions
|
|
@ -1,9 +1,9 @@
|
|||
use nix_compat::derivation::DerivationError;
|
||||
use nix_compat::{derivation::DerivationError, nixhash};
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors related to derivation construction
|
||||
#[derive(Debug, Error, PartialEq)]
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error("an output with the name '{0}' is already defined")]
|
||||
DuplicateOutput(String),
|
||||
|
|
@ -15,18 +15,10 @@ pub enum Error {
|
|||
ShadowedOutput(String),
|
||||
#[error("invalid derivation parameters: {0}")]
|
||||
InvalidDerivation(DerivationError),
|
||||
#[error("invalid output hash: {0}")]
|
||||
InvalidOutputHash(nixhash::Error),
|
||||
#[error("invalid output hash mode: '{0}', only 'recursive' and 'flat` are supported")]
|
||||
InvalidOutputHashMode(String),
|
||||
#[error("unsupported sri algorithm: {0}, only sha1, sha256 or sha512 is supported")]
|
||||
UnsupportedSRIAlgo(String),
|
||||
#[error("invalid number of sri hashes in string ({0}), only one hash is supported")]
|
||||
UnsupportedSRIMultiple(usize),
|
||||
#[error("invalid sri digest: {0}")]
|
||||
InvalidSRIDigest(data_encoding::DecodeError),
|
||||
#[error("failed to parse SRI string: {0}")]
|
||||
InvalidSRIString(String),
|
||||
#[error("outputHashAlgo is set to {0}, but outputHash contains SRI with algo {1}")]
|
||||
ConflictingSRIHashAlgo(String, String),
|
||||
}
|
||||
|
||||
impl From<Error> for tvix_eval::ErrorKind {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue