From 3e03e59893b77b0b3915224967b377f6e940670d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 6 Jan 2023 20:20:44 +0300 Subject: refactor(tvix/store): move protobuf build config one level up This embeds the build config directly at the point where `Cargo.nix` is imported, making it transparent to library consumers. Change-Id: I5586e12f02ed14587c32d9ef7d93f079366fb127 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7780 Autosubmit: tazjin Reviewed-by: flokli Tested-by: BuildkiteCI --- tvix/store/default.nix | 36 +----------------------------------- tvix/store/protos/default.nix | 12 ++++++++++++ 2 files changed, 13 insertions(+), 35 deletions(-) create mode 100644 tvix/store/protos/default.nix (limited to 'tvix/store') 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 -- cgit 1.4.1