2023-02-01 00:30:22 +01:00
|
|
|
use nix_compat::{derivation::DerivationError, nixhash};
|
2023-01-26 23:42:10 +01:00
|
|
|
use std::rc::Rc;
|
|
|
|
use thiserror::Error;
|
2023-01-16 13:27:33 +03:00
|
|
|
|
2023-01-26 23:42:10 +01:00
|
|
|
/// Errors related to derivation construction
|
2023-02-01 00:30:22 +01:00
|
|
|
#[derive(Debug, Error)]
|
2023-01-16 13:27:33 +03:00
|
|
|
pub enum Error {
|
2023-01-26 23:42:10 +01:00
|
|
|
#[error("an output with the name '{0}' is already defined")]
|
2023-01-16 13:27:33 +03:00
|
|
|
DuplicateOutput(String),
|
2023-01-26 23:42:10 +01:00
|
|
|
#[error("fixed-output derivations can only have the default `out`-output")]
|
2023-01-16 13:27:33 +03:00
|
|
|
ConflictingOutputTypes,
|
2023-01-26 23:42:10 +01:00
|
|
|
#[error("the environment variable '{0}' has already been set in this derivation")]
|
2023-01-16 13:27:33 +03:00
|
|
|
DuplicateEnvVar(String),
|
2023-01-26 23:42:10 +01:00
|
|
|
#[error("invalid derivation parameters: {0}")]
|
2023-01-16 13:27:33 +03:00
|
|
|
InvalidDerivation(DerivationError),
|
2023-02-01 00:30:22 +01:00
|
|
|
#[error("invalid output hash: {0}")]
|
|
|
|
InvalidOutputHash(nixhash::Error),
|
2023-01-26 23:42:10 +01:00
|
|
|
#[error("invalid output hash mode: '{0}', only 'recursive' and 'flat` are supported")]
|
2023-01-23 01:28:27 +03:00
|
|
|
InvalidOutputHashMode(String),
|
2023-01-16 13:27:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Error> for tvix_eval::ErrorKind {
|
|
|
|
fn from(err: Error) -> Self {
|
|
|
|
tvix_eval::ErrorKind::TvixError(Rc::new(err))
|
|
|
|
}
|
|
|
|
}
|