about summary refs log tree commit diff
path: root/tvix/glue/src
diff options
context:
space:
mode:
authorPeter Kolloch <info@eigenvalue.net>2024-02-21T11·31+0700
committerclbot <clbot@tvl.fyi>2024-02-21T11·38+0000
commitfde488ec6dc444561ae353f979d87c8ae87261fb (patch)
treec9b673d9d0fc19709f61c88ceb59092f11d7facd /tvix/glue/src
parent035f617b7f11f2ec4a9e08e3a31a175e71a6544b (diff)
feat(tvix/nix-compat): Use `StorePath` in `Output` r/7585
https: //b.tvl.fyi/issues/264
Change-Id: Icb09be9643245cc68d09f01d7723af2d44d6bd1a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11001
Autosubmit: Peter Kolloch <info@eigenvalue.net>
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/glue/src')
-rw-r--r--tvix/glue/src/builtins/derivation.rs4
-rw-r--r--tvix/glue/src/known_paths.rs8
-rw-r--r--tvix/glue/src/tvix_build.rs2
-rw-r--r--tvix/glue/src/tvix_store_io.rs17
4 files changed, 10 insertions, 21 deletions
diff --git a/tvix/glue/src/builtins/derivation.rs b/tvix/glue/src/builtins/derivation.rs
index 87ae8bb946bd..b597d20211e9 100644
--- a/tvix/glue/src/builtins/derivation.rs
+++ b/tvix/glue/src/builtins/derivation.rs
@@ -116,7 +116,7 @@ fn handle_fixed_output(
         drv.outputs.insert(
             "out".to_string(),
             Output {
-                path: "".to_string(),
+                path: None,
                 ca_hash: match hash_mode_str.as_deref() {
                     None | Some("flat") => Some(nixhash::CAHash::Flat(nixhash)),
                     Some("recursive") => Some(nixhash::CAHash::Nar(nixhash)),
@@ -486,7 +486,7 @@ pub(crate) mod derivation_builtins {
                 (
                     name.clone(),
                     (
-                        output.path,
+                        output.path.unwrap().to_absolute_path(),
                         Some(
                             NixContextElement::Single {
                                 name,
diff --git a/tvix/glue/src/known_paths.rs b/tvix/glue/src/known_paths.rs
index bac7e34a7ec4..13f86fae0ea4 100644
--- a/tvix/glue/src/known_paths.rs
+++ b/tvix/glue/src/known_paths.rs
@@ -74,14 +74,8 @@ impl KnownPaths {
         // For all output paths, update our lookup table.
         // We only write into the lookup table once.
         for output in drv.outputs.values() {
-            // We assume derivations to be passed validated, so ignoring rest
-            // and expecting parsing is ok.
-            // TODO: b/264
-            let (output_path, _rest) =
-                StorePath::from_absolute_path_full(&output.path).expect("parse output path");
-
             self.outputs_to_drvpath
-                .entry(output_path)
+                .entry(output.path.as_ref().expect("missing store path").clone())
                 .or_insert(drv_path.to_owned());
         }
 
diff --git a/tvix/glue/src/tvix_build.rs b/tvix/glue/src/tvix_build.rs
index dc48987bd9d2..e9eb1725ef3e 100644
--- a/tvix/glue/src/tvix_build.rs
+++ b/tvix/glue/src/tvix_build.rs
@@ -52,7 +52,7 @@ pub(crate) fn derivation_to_build_request(
     let mut output_paths: Vec<String> = derivation
         .outputs
         .values()
-        .map(|e| e.path[1..].to_owned())
+        .map(|e| e.path_str()[1..].to_owned())
         .collect();
 
     // Sort the outputs. We can use sort_unstable, as these are unique strings.
diff --git a/tvix/glue/src/tvix_store_io.rs b/tvix/glue/src/tvix_store_io.rs
index 296a369e29c1..333b04b170c7 100644
--- a/tvix/glue/src/tvix_store_io.rs
+++ b/tvix/glue/src/tvix_store_io.rs
@@ -4,10 +4,7 @@ use async_recursion::async_recursion;
 use bytes::Bytes;
 use futures::Stream;
 use futures::{StreamExt, TryStreamExt};
-use nix_compat::{
-    nixhash::CAHash,
-    store_path::{StorePath, StorePathRef},
-};
+use nix_compat::{nixhash::CAHash, store_path::StorePath};
 use std::{
     cell::RefCell,
     collections::BTreeSet,
@@ -153,16 +150,14 @@ impl TvixStoreIO {
                             let output_paths: Vec<StorePath> = output_names
                                 .iter()
                                 .map(|output_name| {
-                                    let output_path = &input_drv
+                                    input_drv
                                         .outputs
                                         .get(output_name)
                                         .expect("missing output_name")
-                                        .path;
-
-                                    // since Derivation is validated, we this can be parsed.
-                                    StorePathRef::from_absolute_path(output_path.as_bytes())
-                                        .expect("invalid output path")
-                                        .to_owned()
+                                        .path
+                                        .as_ref()
+                                        .expect("missing output path")
+                                        .clone()
                                 })
                                 .collect();
                             // For each output, ask for the castore node.