fix(nix-compat/derivation): handle dups

This now properly checks for duplicate output names in input derivation
output names, and duplicate input sources.

Change-Id: I0053854bfbf504f4f511fb3fe1a77a82b3aa61dd
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9738
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
Florian Klink 2023-10-15 09:29:48 +01:00 committed by clbot
parent 2410f2292f
commit 8934b34489
2 changed files with 173 additions and 23 deletions

View file

@ -6,15 +6,23 @@ use crate::nixhash;
pub type NomResult<I, O> = IResult<I, O, NomError<I>>;
#[derive(Debug, PartialEq)]
#[derive(Debug, thiserror::Error, PartialEq)]
pub enum ErrorKind {
// duplicate key in map
/// duplicate key in map
#[error("duplicate map key: {0}")]
DuplicateMapKey(String),
// Digest parsing error
/// Input derivation has two outputs with the same name
#[error("duplicate output name {1} for input derivation {0}")]
DuplicateInputDerivationOutputName(String, String),
#[error("duplicate input source: {0}")]
DuplicateInputSource(String),
#[error("nix hash error: {0}")]
NixHashError(nixhash::Error),
// error kind wrapped from native nom errors
#[error("nom error: {0:?}")]
Nom(nom::error::ErrorKind),
}