about summary refs log tree commit diff
path: root/tvix/store
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-01-02T13·37+0100
committerflokli <flokli@flokli.de>2023-01-03T13·03+0000
commitceb2c0ba895554c7cabb0ac20d3a80ea2aba1ab1 (patch)
tree427ee29cd8883bc1159a58e7f6e92a8d673b155e /tvix/store
parentd0bbc8c8214fe164be572a0c2b1bd28f79fc1d20 (diff)
chore(tvix/store): make importable r/5569
This allows other crates to import tvix_store.

Rename the bin crate to tvix-store-bin, to avoid having multiple crates
with the same name (https://github.com/rust-lang/cargo/issues/6313)

Change-Id: I857768d6115640dbf102e79ed03e8474090df2fe
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7728
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/store')
-rw-r--r--tvix/store/Cargo.toml5
-rw-r--r--tvix/store/default.nix7
-rw-r--r--tvix/store/src/lib.rs10
-rw-r--r--tvix/store/src/main.rs24
4 files changed, 27 insertions, 19 deletions
diff --git a/tvix/store/Cargo.toml b/tvix/store/Cargo.toml
index 111667cd74d1..abbd9b0dcbcd 100644
--- a/tvix/store/Cargo.toml
+++ b/tvix/store/Cargo.toml
@@ -1,8 +1,11 @@
 [package]
-name = "tvix-store"
+name = "tvix-store-bin"
 version = "0.1.0"
 edition = "2021"
 
+[lib]
+name = "tvix_store"
+
 [dependencies]
 anyhow = "1.0.68"
 blake3 = { version = "1.3.1", features = ["rayon", "std"] }
diff --git a/tvix/store/default.nix b/tvix/store/default.nix
index 68b529e723b1..65289cacc87c 100644
--- a/tvix/store/default.nix
+++ b/tvix/store/default.nix
@@ -11,7 +11,7 @@ let
 
   protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ];
 in
-depot.tvix.crates.workspaceMembers.tvix-store.build.override {
+depot.tvix.crates.workspaceMembers.tvix-store-bin.build.override {
   # Ensure protobuf dependencies are available.
   # TODO: figure out a way to embed this directly in the //tvix
   # crate2nix config.
@@ -28,6 +28,11 @@ depot.tvix.crates.workspaceMembers.tvix-store.build.override {
       PROTO_ROOT = protoRoot;
       nativeBuildInputs = protobufDep prev;
     };
+
+    tvix-store-bin = prev: {
+      PROTO_ROOT = protoRoot;
+      nativeBuildInputs = protobufDep prev;
+    };
   };
 
   runTests = true;
diff --git a/tvix/store/src/lib.rs b/tvix/store/src/lib.rs
new file mode 100644
index 000000000000..de1cd6557331
--- /dev/null
+++ b/tvix/store/src/lib.rs
@@ -0,0 +1,10 @@
+pub mod nixbase32;
+pub mod nixpath;
+pub mod proto;
+
+pub mod dummy_blob_service;
+pub mod dummy_directory_service;
+pub mod dummy_path_info_service;
+
+#[cfg(test)]
+mod tests;
diff --git a/tvix/store/src/main.rs b/tvix/store/src/main.rs
index 0ba49e3bfd4c..0ad1857db6bc 100644
--- a/tvix/store/src/main.rs
+++ b/tvix/store/src/main.rs
@@ -1,24 +1,14 @@
-use crate::proto::blob_service_server::BlobServiceServer;
-use crate::proto::directory_service_server::DirectoryServiceServer;
-use crate::proto::path_info_service_server::PathInfoServiceServer;
+use tvix_store::proto::blob_service_server::BlobServiceServer;
+use tvix_store::proto::directory_service_server::DirectoryServiceServer;
+use tvix_store::proto::path_info_service_server::PathInfoServiceServer;
 
 #[cfg(feature = "reflection")]
-use crate::proto::FILE_DESCRIPTOR_SET;
+use tvix_store::proto::FILE_DESCRIPTOR_SET;
 
 use clap::Parser;
 use tonic::{transport::Server, Result};
 use tracing::{info, Level};
 
-mod dummy_blob_service;
-mod dummy_directory_service;
-mod dummy_path_info_service;
-mod nixbase32;
-mod nixpath;
-mod proto;
-
-#[cfg(test)]
-mod tests;
-
 #[derive(Parser)]
 #[command(author, version, about, long_about = None)]
 struct Cli {
@@ -44,9 +34,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
 
     let mut server = Server::builder();
 
-    let blob_service = dummy_blob_service::DummyBlobService {};
-    let directory_service = dummy_directory_service::DummyDirectoryService {};
-    let path_info_service = dummy_path_info_service::DummyPathInfoService {};
+    let blob_service = tvix_store::dummy_blob_service::DummyBlobService {};
+    let directory_service = tvix_store::dummy_directory_service::DummyDirectoryService {};
+    let path_info_service = tvix_store::dummy_path_info_service::DummyPathInfoService {};
 
     let mut router = server
         .add_service(BlobServiceServer::new(blob_service))