From 3d8aafb1c73048bfa6b6dee6cc52b81c5d23e4ca Mon Sep 17 00:00:00 2001 From: Ryan Lahfa Date: Wed, 17 Jan 2024 08:06:30 +0100 Subject: feat(tvix/store): enable `name` customization in the store 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 Reviewed-by: flokli --- tvix/store/src/bin/tvix-store.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'tvix/store/src/bin/tvix-store.rs') diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs index 9b07117d71ff..ecee8d78f3b7 100644 --- a/tvix/store/src/bin/tvix-store.rs +++ b/tvix/store/src/bin/tvix-store.rs @@ -305,16 +305,19 @@ async fn main() -> Result<(), Box> { let path_info_service = path_info_service.clone(); async move { - let resp = tvix_store::import::import_path_as_nar_ca( - path, - blob_service, - directory_service, - path_info_service, - ) - .await; - if let Ok(output_path) = resp { - // If the import was successful, print the path to stdout. - println!("{}", output_path.to_absolute_path()); + if let Ok(name) = tvix_store::import::path_to_name(&path) { + let resp = tvix_store::import::import_path_as_nar_ca( + &path, + name, + blob_service, + directory_service, + path_info_service, + ) + .await; + if let Ok(output_path) = resp { + // If the import was successful, print the path to stdout. + println!("{}", output_path.to_absolute_path()); + } } } }) -- cgit 1.4.1