about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/derivation/src/derivation.rs15
-rw-r--r--tvix/derivation/src/errors.rs2
-rw-r--r--tvix/derivation/src/lib.rs2
-rw-r--r--tvix/derivation/src/validate.rs38
4 files changed, 23 insertions, 34 deletions
diff --git a/tvix/derivation/src/derivation.rs b/tvix/derivation/src/derivation.rs
index daccfad6c42e..d937bd91a7fa 100644
--- a/tvix/derivation/src/derivation.rs
+++ b/tvix/derivation/src/derivation.rs
@@ -1,6 +1,6 @@
 use crate::output::{Hash, Output};
 use crate::write;
-use crate::{nix_hash, ValidateDerivationError};
+use crate::{nix_hash, DerivationError};
 use serde::{Deserialize, Serialize};
 use sha2::{Digest, Sha256};
 use std::collections::BTreeSet;
@@ -35,7 +35,7 @@ fn build_store_path(
     is_derivation: bool,
     path_hash: &[u8],
     name: &str,
-) -> Result<StorePath, ValidateDerivationError> {
+) -> Result<StorePath, DerivationError> {
     let compressed = nix_hash::compress_hash(path_hash, 20);
     if is_derivation {
         StorePath::from_string(
@@ -50,9 +50,9 @@ fn build_store_path(
     } else {
         StorePath::from_string(format!("{}-{}", NIXBASE32.encode(&compressed), name,).as_str())
     }
-    .map_err(|_e| ValidateDerivationError::InvalidOutputName(name.to_string()))
+    .map_err(|_e| DerivationError::InvalidOutputName(name.to_string()))
     // Constructing the StorePath can only fail if the passed output name was
-    // invalid, so map errors to a [ValidateDerivationError::InvalidOutputName].
+    // invalid, so map errors to a [DerivationError::InvalidOutputName].
 }
 
 impl Derivation {
@@ -110,10 +110,7 @@ impl Derivation {
     ///   - Take the digest, run hash.CompressHash(digest, 20) on it.
     ///   - Encode it with nixbase32
     ///   - Use it (and the name) to construct a [StorePath].
-    pub fn calculate_derivation_path(
-        &self,
-        name: &str,
-    ) -> Result<StorePath, ValidateDerivationError> {
+    pub fn calculate_derivation_path(&self, name: &str) -> Result<StorePath, DerivationError> {
         let mut hasher = Sha256::new();
 
         // collect the list of paths from input_sources and input_derivations
@@ -230,7 +227,7 @@ impl Derivation {
         &mut self,
         name: &str,
         drv_replacement_str: &str,
-    ) -> Result<(), ValidateDerivationError> {
+    ) -> Result<(), DerivationError> {
         let mut hasher = Sha256::new();
 
         // Check if the Derivation is fixed output, because they cause
diff --git a/tvix/derivation/src/errors.rs b/tvix/derivation/src/errors.rs
index a43162c1460a..baf1d6ca5398 100644
--- a/tvix/derivation/src/errors.rs
+++ b/tvix/derivation/src/errors.rs
@@ -3,7 +3,7 @@ use tvix_store::store_path::ParseStorePathError;
 
 /// Errors that can occur during the validation of Derivation structs.
 #[derive(Debug, Error)]
-pub enum ValidateDerivationError {
+pub enum DerivationError {
     // outputs
     #[error("No outputs defined.")]
     NoOutputs(),
diff --git a/tvix/derivation/src/lib.rs b/tvix/derivation/src/lib.rs
index 00a8e45022df..6134ffb02a4c 100644
--- a/tvix/derivation/src/lib.rs
+++ b/tvix/derivation/src/lib.rs
@@ -12,5 +12,5 @@ mod tests;
 // Public API of the crate.
 
 pub use derivation::Derivation;
-pub use errors::ValidateDerivationError;
+pub use errors::DerivationError;
 pub use output::{Hash, Output};
diff --git a/tvix/derivation/src/validate.rs b/tvix/derivation/src/validate.rs
index b5ba4f72ca28..65809ef5e5f3 100644
--- a/tvix/derivation/src/validate.rs
+++ b/tvix/derivation/src/validate.rs
@@ -1,13 +1,13 @@
-use crate::{derivation::Derivation, write::DOT_FILE_EXT, ValidateDerivationError};
+use crate::{derivation::Derivation, write::DOT_FILE_EXT, DerivationError};
 use tvix_store::store_path::StorePath;
 
 impl Derivation {
     /// validate ensures a Derivation struct is properly populated,
     /// and returns a [ValidateDerivationError] if not.
-    pub fn validate(&self) -> Result<(), ValidateDerivationError> {
+    pub fn validate(&self) -> Result<(), DerivationError> {
         // Ensure the number of outputs is > 1
         if self.outputs.is_empty() {
-            return Err(ValidateDerivationError::NoOutputs());
+            return Err(DerivationError::NoOutputs());
         }
 
         // Validate all outputs
@@ -22,17 +22,15 @@ impl Derivation {
             // Other output names that don't match the name restrictions from
             // [StorePath] will fail output path calculation.
             if output_name.is_empty() || output_name == "drv" {
-                return Err(ValidateDerivationError::InvalidOutputName(
-                    output_name.to_string(),
-                ));
+                return Err(DerivationError::InvalidOutputName(output_name.to_string()));
             }
 
             if output.is_fixed() {
                 if self.outputs.len() != 1 {
-                    return Err(ValidateDerivationError::MoreThanOneOutputButFixed());
+                    return Err(DerivationError::MoreThanOneOutputButFixed());
                 }
                 if output_name != "out" {
-                    return Err(ValidateDerivationError::InvalidOutputNameForFixed(
+                    return Err(DerivationError::InvalidOutputNameForFixed(
                         output_name.to_string(),
                     ));
                 }
@@ -41,7 +39,7 @@ impl Derivation {
             }
 
             if let Err(e) = output.validate() {
-                return Err(ValidateDerivationError::InvalidOutputPath(
+                return Err(DerivationError::InvalidOutputPath(
                     output_name.to_string(),
                     e,
                 ));
@@ -52,20 +50,20 @@ impl Derivation {
         for (input_derivation_path, output_names) in &self.input_derivations {
             // Validate input_derivation_path
             if let Err(e) = StorePath::from_absolute_path(input_derivation_path) {
-                return Err(ValidateDerivationError::InvalidInputDerivationPath(
+                return Err(DerivationError::InvalidInputDerivationPath(
                     input_derivation_path.to_string(),
                     e,
                 ));
             }
 
             if !input_derivation_path.ends_with(DOT_FILE_EXT) {
-                return Err(ValidateDerivationError::InvalidInputDerivationPrefix(
+                return Err(DerivationError::InvalidInputDerivationPrefix(
                     input_derivation_path.to_string(),
                 ));
             }
 
             if output_names.is_empty() {
-                return Err(ValidateDerivationError::EmptyInputDerivationOutputNames(
+                return Err(DerivationError::EmptyInputDerivationOutputNames(
                     input_derivation_path.to_string(),
                 ));
             }
@@ -82,7 +80,7 @@ impl Derivation {
                 // from [StorePath] can't be constructed with this library, but
                 // are not explicitly checked here (yet).
                 if output_name.is_empty() || output_name == "drv" {
-                    return Err(ValidateDerivationError::InvalidInputDerivationOutputName(
+                    return Err(DerivationError::InvalidInputDerivationOutputName(
                         input_derivation_path.to_string(),
                         output_name.to_string(),
                     ));
@@ -93,7 +91,7 @@ impl Derivation {
         // Validate all input_sources
         for input_source in self.input_sources.iter() {
             if let Err(e) = StorePath::from_absolute_path(input_source) {
-                return Err(ValidateDerivationError::InvalidInputSourcesPath(
+                return Err(DerivationError::InvalidInputSourcesPath(
                     input_source.to_string(),
                     e,
                 ));
@@ -102,25 +100,19 @@ impl Derivation {
 
         // validate platform
         if self.system.is_empty() {
-            return Err(ValidateDerivationError::InvalidPlatform(
-                self.system.to_string(),
-            ));
+            return Err(DerivationError::InvalidPlatform(self.system.to_string()));
         }
 
         // validate builder
         if self.builder.is_empty() {
-            return Err(ValidateDerivationError::InvalidBuilder(
-                self.builder.to_string(),
-            ));
+            return Err(DerivationError::InvalidBuilder(self.builder.to_string()));
         }
 
         // validate env, none of the keys may be empty.
         // We skip the `name` validation seen in go-nix.
         for k in self.environment.keys() {
             if k.is_empty() {
-                return Err(ValidateDerivationError::InvalidEnvironmentKey(
-                    k.to_string(),
-                ));
+                return Err(DerivationError::InvalidEnvironmentKey(k.to_string()));
             }
         }