about summary refs log tree commit diff
path: root/buildGo.nix
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2019-11-26T12·16+0000
committerVincent Ambo <tazjin@google.com>2019-11-26T12·28+0000
commit9280cf97151fd14269342310ad1acfb6ccd37369 (patch)
tree3a77ecdfb3b4ab47fe6fd51361599e4dd51ea729 /buildGo.nix
parentd3e8774a8e159984bfa2864d383a1d9b641a4c6f (diff)
feat(buildGo): Add support for gRPC packages
Introduces buildGo.grpc which is like buildGo.proto, but adds
dependencies on the gRPC libraries.
Diffstat (limited to 'buildGo.nix')
-rw-r--r--buildGo.nix13
1 files changed, 8 insertions, 5 deletions
diff --git a/buildGo.nix b/buildGo.nix
index bf8625c1b4..fba4e18e9b 100644
--- a/buildGo.nix
+++ b/buildGo.nix
@@ -72,17 +72,20 @@ let
   '') // { goDeps = uniqueDeps; };
 
   # Build a Go library out of the specified protobuf definition.
-  proto = { name, proto, path ? name, protocFlags ? "", extraDeps ? [] }: package {
+  proto = { name, proto, path ? name, extraDeps ? [] }: package {
     inherit name path;
-    deps = [ goProto ] ++ extraDeps;
+    deps = [ protoLibs.goProto ] ++ extraDeps;
     srcs = lib.singleton (runCommand "goproto-${name}.pb.go" {} ''
       cp ${proto} ${baseNameOf proto}
-      ${protobuf}/bin/protoc --plugin=${goProto}/bin/protoc-gen-go \
-        --go_out=${protocFlags}import_path=${baseNameOf path}:. ${baseNameOf proto}
+      ${protobuf}/bin/protoc --plugin=${protoLibs.goProto}/bin/protoc-gen-go \
+        --go_out=plugins=grpc,import_path=${baseNameOf path}:. ${baseNameOf proto}
       mv *.pb.go $out
     '');
   };
 
+  # Build a Go library out of the specified gRPC definition.
+  grpc = args: proto (args // { extraDeps = [ protoLibs.goGrpc ]; });
+
   # Build an externally defined Go library using `go build` itself.
   #
   # Libraries built this way can be included in any standard buildGo
@@ -128,5 +131,5 @@ let
   };
 in {
   # Only the high-level builder functions are exposed
-  inherit program package proto external;
+  inherit program package proto grpc external;
 }