about summary refs log tree commit diff
path: root/tvix/store/src
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/store/src')
-rw-r--r--tvix/store/src/nixpath.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/tvix/store/src/nixpath.rs b/tvix/store/src/nixpath.rs
index e7329b527c5c..54b964e83f04 100644
--- a/tvix/store/src/nixpath.rs
+++ b/tvix/store/src/nixpath.rs
@@ -71,6 +71,12 @@ impl NixPath {
         }
     }
 
+    // Converts the NixPath to an absolute store path string.
+    /// That is a string starting with the store prefix (/nix/store)
+    pub fn to_absolute_path(&self) -> String {
+        format!("{}/{}", STORE_DIR, self)
+    }
+
     fn validate_characters(s: &str) -> Result<(), ParseNixPathError> {
         for c in s.chars() {
             if c.is_ascii_alphanumeric()
@@ -170,6 +176,11 @@ mod tests {
         .expect("must parse");
 
         assert_eq!(nixpath_expected, nixpath_actual);
+
+        assert_eq!(
+            "/nix/store/00bgd045z0d4icpbc2yyz4gx48ak44la-net-tools-1.60_p20170221182432",
+            nixpath_actual.to_absolute_path(),
+        );
     }
 
     #[test]