From 99d5cf822a969c5de54639e46f9be917b7cd6119 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Wed, 1 Feb 2023 00:30:22 +0100 Subject: 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 --- tvix/cli/src/errors.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'tvix/cli/src/errors.rs') diff --git a/tvix/cli/src/errors.rs b/tvix/cli/src/errors.rs index 5315b24864..6f328dc000 100644 --- a/tvix/cli/src/errors.rs +++ b/tvix/cli/src/errors.rs @@ -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 for tvix_eval::ErrorKind { -- cgit 1.4.1