about summary refs log tree commit diff
path: root/tvix/store/src/proto
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-03-30T12·01+0200
committerclbot <clbot@tvl.fyi>2023-03-30T14·03+0000
commit5f2c2e79e1778cda877d6122dd24be08740c8720 (patch)
treeb87dba0063a193a39c1bf57a2b1e3513039e144c /tvix/store/src/proto
parent4ab180b1ebf411d7d7ebd98ae17c25945b17e2c2 (diff)
refactor(tvix/nix-compat): move build_store_path out of derivation r/6060
This doesn't have anything to do with ATerms, we just happen to be using
the aterm representation of a Derivation as contents.

Moving this into store_path/utils.rs makes these things much cleaner -
Have a build_store_path_from_references function, and a
build_store_path_from_fingerprint helper function that makes use of it.

build_store_path_from_references is invoked from the derivation module
which can be used to calculate the derivation path.

In the derivation module, we also invoke
build_store_path_from_fingerprint during the output path calculation.

Change-Id: Ia8d61a5e8e5d3f396f93593676ed3f5d1a3f1d66
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8367
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/store/src/proto')
-rw-r--r--tvix/store/src/proto/mod.rs6
-rw-r--r--tvix/store/src/proto/tests/pathinfo.rs8
2 files changed, 7 insertions, 7 deletions
diff --git a/tvix/store/src/proto/mod.rs b/tvix/store/src/proto/mod.rs
index f5945d650ad8..5002d7e77a96 100644
--- a/tvix/store/src/proto/mod.rs
+++ b/tvix/store/src/proto/mod.rs
@@ -5,7 +5,7 @@ use thiserror::Error;
 
 use prost::Message;
 
-use nix_compat::store_path::{ParseStorePathError, StorePath};
+use nix_compat::store_path::{self, StorePath};
 
 mod grpc_blobservice_wrapper;
 mod grpc_directoryservice_wrapper;
@@ -52,7 +52,7 @@ pub enum ValidatePathInfoError {
 
     /// Invalid node name encountered.
     #[error("Failed to parse {0} as NixPath: {1}")]
-    InvalidNodeName(String, ParseStorePathError),
+    InvalidNodeName(String, store_path::Error),
 
     /// The digest the (root) node refers to has invalid length.
     #[error("Invalid Digest length: {0}")]
@@ -91,7 +91,7 @@ fn validate_digest<E>(digest: &Vec<u8>, err: fn(usize) -> E) -> Result<(), E> {
 /// On error, it returns an error generated from the supplied constructor.
 fn parse_node_name_root<E>(
     name: &str,
-    err: fn(String, ParseStorePathError) -> E,
+    err: fn(String, store_path::Error) -> E,
 ) -> Result<StorePath, E> {
     match StorePath::from_string(name) {
         Ok(np) => Ok(np),
diff --git a/tvix/store/src/proto/tests/pathinfo.rs b/tvix/store/src/proto/tests/pathinfo.rs
index 584bc5920684..0cc8f87587f1 100644
--- a/tvix/store/src/proto/tests/pathinfo.rs
+++ b/tvix/store/src/proto/tests/pathinfo.rs
@@ -1,6 +1,6 @@
 use crate::proto::{self, Node, PathInfo, ValidatePathInfoError};
 use lazy_static::lazy_static;
-use nix_compat::store_path::{ParseStorePathError, StorePath};
+use nix_compat::store_path::{self, StorePath};
 use test_case::test_case;
 
 lazy_static! {
@@ -66,7 +66,7 @@ fn validate_no_node(
     },
     Err(ValidatePathInfoError::InvalidNodeName(
         "invalid".to_string(),
-        ParseStorePathError::InvalidName("".to_string())
+        store_path::Error::InvalidName("".to_string())
     ));
     "invalid node name"
 )]
@@ -111,7 +111,7 @@ fn validate_directory(
     },
     Err(ValidatePathInfoError::InvalidNodeName(
         "invalid".to_string(),
-        ParseStorePathError::InvalidName("".to_string())
+        store_path::Error::InvalidName("".to_string())
     ));
     "invalid node name"
 )]
@@ -141,7 +141,7 @@ fn validate_file(t_file_node: proto::FileNode, t_result: Result<StorePath, Valid
     },
     Err(ValidatePathInfoError::InvalidNodeName(
         "invalid".to_string(),
-        ParseStorePathError::InvalidName("".to_string())
+        store_path::Error::InvalidName("".to_string())
     ));
     "invalid node name"
 )]