about summary refs log tree commit diff
path: root/tvix/store/src/import.rs
diff options
context:
space:
mode:
authorRyan Lahfa <tvl@lahfa.xyz>2024-01-17T07·06+0100
committerclbot <clbot@tvl.fyi>2024-01-20T18·35+0000
commit3d8aafb1c73048bfa6b6dee6cc52b81c5d23e4ca (patch)
treeec48cfe801b59f24b9b4e7dfa4ced0594c20d11a /tvix/store/src/import.rs
parent4c3ba46ba36b2fa2d9079fcc92ef27875f26418b (diff)
feat(tvix/store): enable `name` customization in the store r/7433
Sometimes, Nix lets someone customize the `name` in the store for a
path, this is the case for `builtins.path` which takes a `name`
argument, we leave it to the caller to choose the name, which can be the
basename by default of the path.

Change-Id: Icdbf71d1d8f2dca5716b99d20aac885aab905b80
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10653
Tested-by: BuildkiteCI
Autosubmit: raitobezarius <tvl@lahfa.xyz>
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/store/src/import.rs')
-rw-r--r--tvix/store/src/import.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/tvix/store/src/import.rs b/tvix/store/src/import.rs
index 84c73e1554..588a010893 100644
--- a/tvix/store/src/import.rs
+++ b/tvix/store/src/import.rs
@@ -13,7 +13,7 @@ use crate::{
     proto::{nar_info, NarInfo, PathInfo},
 };
 
-fn log_node(node: &Node, path: &Path) {
+pub fn log_node(node: &Node, path: &Path) {
     match node {
         Node::Directory(directory_node) => {
             debug!(
@@ -86,9 +86,10 @@ pub fn derive_nar_ca_path_info(nar_size: u64, nar_sha256: [u8; 32], root_node: N
 
 /// Ingest the given path [`path`] and register the resulting output path in the
 /// [`PathInfoService`] as a recursive fixed output NAR.
-#[instrument(skip_all, fields(path=?path), err)]
+#[instrument(skip_all, fields(store_name=name, path=?path), err)]
 pub async fn import_path_as_nar_ca<BS, DS, PS, P>(
     path: P,
+    name: &str,
     blob_service: BS,
     directory_service: DS,
     path_info_service: PS,
@@ -106,9 +107,8 @@ where
     let (nar_size, nar_sha256) = path_info_service.as_ref().calculate_nar(&root_node).await?;
 
     // Calculate the output path. This might still fail, as some names are illegal.
-    // FUTUREWORK: take `name` as a parameter here and enforce the validity of the name
-    // at the type level.
-    let name = path_to_name(path.as_ref())?;
+    // FUTUREWORK: express the `name` at the type level to be valid and move the conversion
+    // at the caller level.
     let output_path = store_path::build_nar_based_store_path(&nar_sha256, name).map_err(|_| {
         std::io::Error::new(
             std::io::ErrorKind::InvalidData,