about summary refs log tree commit diff
path: root/tvix/nix-compat/src/derivation/validate.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-07-18T18·34+0300
committerclbot <clbot@tvl.fyi>2023-07-21T18·04+0000
commit42dc18353d99453bc0f83492f9f5bc4796f4cc4c (patch)
tree4f3d2d90106cea54f37620de082c6eb12754a658 /tvix/nix-compat/src/derivation/validate.rs
parent5364fcb12708667a2dc698a689d00d70d1bf75af (diff)
feat(tvix/nix-compat): have StorePath accept bytes r/6433
The primary constructor for this is now from_bytes, from_string is
simply calling .as_bytes() on the string, passing it along.

The InvalidName error now contains a Vec<u8>, to encode the invalid name
(which might not be a string anymore).

from_absolute_path now accepts a &[u8] (even though we might want to
make this a OSString of some sort).

StorePath::validate_name has been degraded to a pub(crate) function.
It's still used in src/derivation, even though it probably shouldn't at
all - that cleanup is left for cl/8412 though.

Change-Id: I6b4e62a6fa5c4bec13b535279e73444f0b83ad35
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8973
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/nix-compat/src/derivation/validate.rs')
-rw-r--r--tvix/nix-compat/src/derivation/validate.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/tvix/nix-compat/src/derivation/validate.rs b/tvix/nix-compat/src/derivation/validate.rs
index d8dc24a92ae1..6b81c4c80b86 100644
--- a/tvix/nix-compat/src/derivation/validate.rs
+++ b/tvix/nix-compat/src/derivation/validate.rs
@@ -1,5 +1,5 @@
 use crate::derivation::{Derivation, DerivationError};
-use crate::store_path::StorePath;
+use crate::store_path::{self, StorePath};
 
 impl Derivation {
     /// validate ensures a Derivation struct is properly populated,
@@ -26,10 +26,10 @@ impl Derivation {
             // meaning.
             //
             // Other output names that don't match the name restrictions from
-            // [StorePath] will fail the [StorePath::validate_name] check.
+            // [StorePath] will fail the [store_path::validate_name] check.
             if output_name.is_empty()
                 || output_name == "drv"
-                || StorePath::validate_name(output_name).is_err()
+                || store_path::validate_name(output_name.as_bytes()).is_err()
             {
                 return Err(DerivationError::InvalidOutputName(output_name.to_string()));
             }
@@ -55,7 +55,7 @@ impl Derivation {
         // Validate all input_derivations
         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) {
+            if let Err(e) = StorePath::from_absolute_path(input_derivation_path.as_bytes()) {
                 return Err(DerivationError::InvalidInputDerivationPath(
                     input_derivation_path.to_string(),
                     e,
@@ -86,7 +86,7 @@ impl Derivation {
                 // [StorePath] will fail the [StorePath::validate_name] check.
                 if output_name.is_empty()
                     || output_name == "drv"
-                    || StorePath::validate_name(output_name).is_err()
+                    || store_path::validate_name(output_name.as_bytes()).is_err()
                 {
                     return Err(DerivationError::InvalidInputDerivationOutputName(
                         input_derivation_path.to_string(),
@@ -98,7 +98,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) {
+            if let Err(e) = StorePath::from_absolute_path(input_source.as_bytes()) {
                 return Err(DerivationError::InvalidInputSourcesPath(
                     input_source.to_string(),
                     e,