about summary refs log tree commit diff
path: root/tvix/derivation/src
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/derivation/src')
-rw-r--r--tvix/derivation/src/output.rs8
-rw-r--r--tvix/derivation/src/tests/mod.rs2
-rw-r--r--tvix/derivation/src/validate.rs8
3 files changed, 12 insertions, 6 deletions
diff --git a/tvix/derivation/src/output.rs b/tvix/derivation/src/output.rs
index 982ac7c9eb79..369efca031f3 100644
--- a/tvix/derivation/src/output.rs
+++ b/tvix/derivation/src/output.rs
@@ -24,10 +24,12 @@ impl Output {
         self.hash.is_some()
     }
 
-    pub fn validate(&self) -> Result<(), OutputError> {
+    pub fn validate(&self, validate_output_paths: bool) -> Result<(), OutputError> {
         // TODO: add validation for hash, hashAlgo
-        if let Err(e) = StorePath::from_absolute_path(&self.path) {
-            return Err(OutputError::InvalidOutputPath(self.path.to_string(), e));
+        if validate_output_paths {
+            if let Err(e) = StorePath::from_absolute_path(&self.path) {
+                return Err(OutputError::InvalidOutputPath(self.path.to_string(), e));
+            }
         }
         Ok(())
     }
diff --git a/tvix/derivation/src/tests/mod.rs b/tvix/derivation/src/tests/mod.rs
index bd5d9f34cb12..5dd60284f05c 100644
--- a/tvix/derivation/src/tests/mod.rs
+++ b/tvix/derivation/src/tests/mod.rs
@@ -39,7 +39,7 @@ fn validate(path_to_drv_file: &str) {
     let derivation: Derivation = serde_json::from_str(&data).expect("JSON was not well-formatted");
 
     derivation
-        .validate()
+        .validate(true)
         .expect("derivation failed to validate")
 }
 
diff --git a/tvix/derivation/src/validate.rs b/tvix/derivation/src/validate.rs
index c6cd2f8b9e3e..8a8c1b506911 100644
--- a/tvix/derivation/src/validate.rs
+++ b/tvix/derivation/src/validate.rs
@@ -4,7 +4,11 @@ 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<(), DerivationError> {
+    /// if `validate_output_paths` is set to false, the output paths are
+    /// excluded from validation.
+    /// This is helpful to validate struct population before invoking
+    /// [Derivation::calculate_output_paths].
+    pub fn validate(&self, validate_output_paths: bool) -> Result<(), DerivationError> {
         // Ensure the number of outputs is > 1
         if self.outputs.is_empty() {
             return Err(DerivationError::NoOutputs());
@@ -41,7 +45,7 @@ impl Derivation {
                 break;
             }
 
-            if let Err(e) = output.validate() {
+            if let Err(e) = output.validate(validate_output_paths) {
                 return Err(DerivationError::InvalidOutput(output_name.to_string(), e));
             }
         }