diff options
author | Vincent Ambo <tazjin@google.com> | 2019-11-26T12·15+0000 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2019-11-26T12·28+0000 |
commit | d3e8774a8e159984bfa2864d383a1d9b641a4c6f (patch) | |
tree | d3c26c233b1dbe493a8ce147b4d2eb359e041d6a | |
parent | 8b6b08b814af72e8b2f6281037f089e099a41e25 (diff) |
feat(proto): Add protobuf & gRPC dependencies via external
Moves the Protobuf & gRPC dependencies to a separate file which uses buildGo.external to build the dependencies. The versions are pinned at master of 2019-11-26.
-rw-r--r-- | buildGo.nix | 14 | ||||
-rw-r--r-- | proto.nix | 72 |
2 files changed, 74 insertions, 12 deletions
diff --git a/buildGo.nix b/buildGo.nix index 12504ce57103..bf8625c1b440 100644 --- a/buildGo.nix +++ b/buildGo.nix @@ -123,18 +123,8 @@ let paths = [ gopathSrc gopathPkg ]; }) // { goDeps = uniqueDeps; }; - # Protobuf & gRPC integration requires these dependencies: - proto-go-src = fetchFromGitHub { - owner = "golang"; - repo = "protobuf"; - rev = "ed6926b37a637426117ccab59282c3839528a700"; - sha256 = "0fynqrim022x9xi2bivkw19npbz4316v4yr7mb677s9s36z4dc4h"; - }; - - goProto = external { - path = "github.com/golang/protobuf"; - src = proto-go-src; - deps = []; + protoLibs = import ./proto.nix { + inherit external; }; in { # Only the high-level builder functions are exposed diff --git a/proto.nix b/proto.nix new file mode 100644 index 000000000000..e773af031873 --- /dev/null +++ b/proto.nix @@ -0,0 +1,72 @@ +# Copyright 2019 Google LLC. +# SPDX-License-Identifier: Apache-2.0 +# +# This file provides derivations for the dependencies of a gRPC +# service in Go. + +{ external }: + +let + inherit (builtins) fetchGit map; +in rec { + goProto = external { + path = "github.com/golang/protobuf"; + src = fetchGit { + url = "https://github.com/golang/protobuf"; + rev = "ed6926b37a637426117ccab59282c3839528a700"; + }; + }; + + xnet = external { + path = "golang.org/x/net"; + srcOnly = true; + deps = [ xtext ]; + src = fetchGit { + url = "https://go.googlesource.com/net"; + rev = "ffdde105785063a81acd95bdf89ea53f6e0aac2d"; + }; + }; + + xsys = external { + path = "golang.org/x/sys"; + srcOnly = true; + src = fetchGit { + url = "https://go.googlesource.com/sys"; + rev = "bd437916bb0eb726b873ee8e9b2dcf212d32e2fd"; + }; + }; + + xtext = external { + path = "golang.org/x/text"; + srcOnly = true; + src = fetchGit { + url = "https://go.googlesource.com/text"; + rev = "cbf43d21aaebfdfeb81d91a5f444d13a3046e686"; + }; + }; + + genproto = external { + path = "google.golang.org/genproto"; + srcOnly = true; + src = fetchGit { + url = "https://github.com/google/go-genproto"; + rev = "83cc0476cb11ea0da33dacd4c6354ab192de6fe6"; + }; + }; + + goGrpc = external { + path = "google.golang.org/grpc"; + deps = [ goProto xnet xsys genproto ]; + + src = fetchGit { + url = "https://github.com/grpc/grpc-go"; + rev = "d8e3da36ac481ef00e510ca119f6b68177713689"; + }; + + targets = [ + "." + "codes" + "status" + ]; + }; +} |