about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/default.nix24
-rw-r--r--tvix/store/default.nix36
-rw-r--r--tvix/store/protos/default.nix12
3 files changed, 37 insertions, 35 deletions
diff --git a/tvix/default.nix b/tvix/default.nix
index d0357fe24ef8..f0da4d05b335 100644
--- a/tvix/default.nix
+++ b/tvix/default.nix
@@ -1,11 +1,35 @@
 # Nix helpers for projects under //tvix
 { pkgs, depot, ... }:
 
+let
+  # crate override for crates that need protobuf
+  protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ];
+in
 {
   # Load the crate2nix crate tree.
   crates = import ./Cargo.nix {
     inherit pkgs;
     nixpkgs = pkgs.path;
+
+    defaultCrateOverrides = pkgs.defaultCrateOverrides // {
+      prost-build = prev: {
+        nativeBuildInputs = protobufDep prev;
+      };
+
+      tonic-reflection = prev: {
+        nativeBuildInputs = protobufDep prev;
+      };
+
+      tvix-store = prev: {
+        PROTO_ROOT = depot.tvix.store.protos;
+        nativeBuildInputs = protobufDep prev;
+      };
+
+      tvix-store-bin = prev: {
+        PROTO_ROOT = depot.tvix.store.protos;
+        nativeBuildInputs = protobufDep prev;
+      };
+    };
   };
 
   # Run crate2nix generate in the current working directory, then
diff --git a/tvix/store/default.nix b/tvix/store/default.nix
index 65289cacc87c..3d873a097ec4 100644
--- a/tvix/store/default.nix
+++ b/tvix/store/default.nix
@@ -1,39 +1,5 @@
-{ depot, pkgs, ... }:
+{ depot, ... }:
 
-let
-  protoRoot = depot.nix.sparseTree depot.path.origSrc [
-    ./protos/castore.proto
-    ./protos/pathinfo.proto
-    ./protos/rpc_blobstore.proto
-    ./protos/rpc_directory.proto
-    ./protos/rpc_pathinfo.proto
-  ];
-
-  protobufDep = prev: (prev.nativeBuildInputs or [ ]) ++ [ pkgs.protobuf ];
-in
 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.
-  crateOverrides = {
-    prost-build = prev: {
-      nativeBuildInputs = protobufDep prev;
-    };
-
-    tonic-reflection = prev: {
-      nativeBuildInputs = protobufDep prev;
-    };
-
-    tvix-store = prev: {
-      PROTO_ROOT = protoRoot;
-      nativeBuildInputs = protobufDep prev;
-    };
-
-    tvix-store-bin = prev: {
-      PROTO_ROOT = protoRoot;
-      nativeBuildInputs = protobufDep prev;
-    };
-  };
-
   runTests = true;
 }
diff --git a/tvix/store/protos/default.nix b/tvix/store/protos/default.nix
new file mode 100644
index 000000000000..0ffdcac0418a
--- /dev/null
+++ b/tvix/store/protos/default.nix
@@ -0,0 +1,12 @@
+# Target containing just the proto files.
+
+{ depot, lib, ... }:
+
+let
+  inherit (lib.strings) hasSuffix;
+  inherit (builtins) attrNames filter readDir;
+
+  protoFileNames = filter (hasSuffix ".proto") (attrNames (readDir ./.));
+  protoFiles = map (f: ./. + ("/" + f)) protoFileNames;
+in
+depot.nix.sparseTree depot.path.origSrc protoFiles