chore(nix/buildGo): drop buildGo.proto and buildGo.grpc
As described in https://b.tvl.fyi/issues/221#comment-344, buildGo.proto was a mistake and should be removed. Change-Id: Ic588a5e8eea58e83e3ec9a37ac681ce526028718 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7536 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
c6cb138565
commit
7fbac93940
3 changed files with 2 additions and 134 deletions
|
@ -2,8 +2,7 @@ buildGo.nix
|
||||||
===========
|
===========
|
||||||
|
|
||||||
This is an alternative [Nix][] build system for [Go][]. It supports building Go
|
This is an alternative [Nix][] build system for [Go][]. It supports building Go
|
||||||
libraries and programs, and even automatically generating Protobuf & gRPC
|
libraries and programs.
|
||||||
libraries.
|
|
||||||
|
|
||||||
*Note:* This will probably end up being folded into [Nixery][].
|
*Note:* This will probably end up being folded into [Nixery][].
|
||||||
|
|
||||||
|
@ -33,7 +32,6 @@ Given a program layout like this:
|
||||||
├── lib <-- some library component
|
├── lib <-- some library component
|
||||||
│ ├── bar.go
|
│ ├── bar.go
|
||||||
│ └── foo.go
|
│ └── foo.go
|
||||||
├── api.proto <-- gRPC API definition
|
|
||||||
├── main.go <-- program implementation
|
├── main.go <-- program implementation
|
||||||
└── default.nix <-- build instructions
|
└── default.nix <-- build instructions
|
||||||
```
|
```
|
||||||
|
@ -44,11 +42,6 @@ The contents of `default.nix` could look like this:
|
||||||
{ buildGo }:
|
{ buildGo }:
|
||||||
|
|
||||||
let
|
let
|
||||||
api = buildGo.grpc {
|
|
||||||
name = "someapi";
|
|
||||||
proto = ./api.proto;
|
|
||||||
};
|
|
||||||
|
|
||||||
lib = buildGo.package {
|
lib = buildGo.package {
|
||||||
name = "somelib";
|
name = "somelib";
|
||||||
srcs = [
|
srcs = [
|
||||||
|
@ -58,7 +51,7 @@ let
|
||||||
};
|
};
|
||||||
in buildGo.program {
|
in buildGo.program {
|
||||||
name = "my-program";
|
name = "my-program";
|
||||||
deps = [ api lib ];
|
deps = [ lib ];
|
||||||
|
|
||||||
srcs = [
|
srcs = [
|
||||||
./main.go
|
./main.go
|
||||||
|
@ -105,22 +98,6 @@ in buildGo.program {
|
||||||
| `src` | `path` | Path to the source **directory** | yes |
|
| `src` | `path` | Path to the source **directory** | yes |
|
||||||
| `deps` | `list<drv>` | List of dependencies (i.e. other Go packages) | no |
|
| `deps` | `list<drv>` | List of dependencies (i.e. other Go packages) | no |
|
||||||
|
|
||||||
For some examples of how `buildGo.external` is used, check out
|
|
||||||
[`proto.nix`](./proto.nix).
|
|
||||||
|
|
||||||
* `buildGo.proto`: Build a Go library out of the specified Protobuf definition.
|
|
||||||
|
|
||||||
| parameter | type | use | required? |
|
|
||||||
|-------------|-------------|--------------------------------------------------|-----------|
|
|
||||||
| `name` | `string` | Name for the resulting library | yes |
|
|
||||||
| `proto` | `path` | Path to the Protobuf definition file | yes |
|
|
||||||
| `path` | `string` | Import path for the resulting Go library | no |
|
|
||||||
| `extraDeps` | `list<drv>` | Additional Go dependencies to add to the library | no |
|
|
||||||
|
|
||||||
* `buildGo.grpc`: Build a Go library out of the specified gRPC definition.
|
|
||||||
|
|
||||||
The parameters are identical to `buildGo.proto`.
|
|
||||||
|
|
||||||
## Current status
|
## Current status
|
||||||
|
|
||||||
This project is work-in-progress. Crucially it is lacking the following features:
|
This project is work-in-progress. Crucially it is lacking the following features:
|
||||||
|
|
|
@ -111,33 +111,11 @@ let
|
||||||
# named "gopkg", and an attribute named "gobin" for binaries.
|
# named "gopkg", and an attribute named "gobin" for binaries.
|
||||||
external = import ./external { inherit pkgs program package; };
|
external = import ./external { inherit pkgs program package; };
|
||||||
|
|
||||||
# Import support libraries needed for protobuf & gRPC support
|
|
||||||
protoLibs = import ./proto.nix {
|
|
||||||
inherit external;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Build a Go library out of the specified protobuf definition.
|
|
||||||
proto = { name, proto, path ? name, goPackage ? name, extraDeps ? [ ] }: (makeOverridable package) {
|
|
||||||
inherit name path;
|
|
||||||
deps = [ protoLibs.goProto.proto.gopkg ] ++ extraDeps;
|
|
||||||
srcs = lib.singleton (runCommand "goproto-${name}.pb.go" { } ''
|
|
||||||
cp ${proto} ${baseNameOf proto}
|
|
||||||
${protobuf}/bin/protoc --plugin=${protoLibs.goProto.protoc-gen-go.gopkg}/bin/protoc-gen-go \
|
|
||||||
--go_out=plugins=grpc,import_path=${baseNameOf path}:. ${baseNameOf proto}
|
|
||||||
mv ./${goPackage}/*.pb.go $out
|
|
||||||
'');
|
|
||||||
};
|
|
||||||
|
|
||||||
# Build a Go library out of the specified gRPC definition.
|
|
||||||
grpc = args: proto (args // { extraDeps = [ protoLibs.goGrpc.gopkg ]; });
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Only the high-level builder functions are exposed, but made
|
# Only the high-level builder functions are exposed, but made
|
||||||
# overrideable.
|
# overrideable.
|
||||||
program = makeOverridable program;
|
program = makeOverridable program;
|
||||||
package = makeOverridable package;
|
package = makeOverridable package;
|
||||||
proto = makeOverridable proto;
|
|
||||||
grpc = makeOverridable grpc;
|
|
||||||
external = makeOverridable external;
|
external = makeOverridable external;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,87 +0,0 @@
|
||||||
# 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";
|
|
||||||
|
|
||||||
src = fetchGit {
|
|
||||||
url = "https://go.googlesource.com/net";
|
|
||||||
rev = "ffdde105785063a81acd95bdf89ea53f6e0aac2d";
|
|
||||||
};
|
|
||||||
|
|
||||||
deps = [
|
|
||||||
xtext.secure.bidirule
|
|
||||||
xtext.unicode.bidi
|
|
||||||
xtext.unicode.norm
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
xsys = external {
|
|
||||||
path = "golang.org/x/sys";
|
|
||||||
src = fetchGit {
|
|
||||||
url = "https://go.googlesource.com/sys";
|
|
||||||
rev = "bd437916bb0eb726b873ee8e9b2dcf212d32e2fd";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
xtext = external {
|
|
||||||
path = "golang.org/x/text";
|
|
||||||
src = fetchGit {
|
|
||||||
url = "https://go.googlesource.com/text";
|
|
||||||
rev = "cbf43d21aaebfdfeb81d91a5f444d13a3046e686";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
genproto = external {
|
|
||||||
path = "google.golang.org/genproto";
|
|
||||||
src = fetchGit {
|
|
||||||
url = "https://github.com/google/go-genproto";
|
|
||||||
# necessary because https://github.com/NixOS/nix/issues/1923
|
|
||||||
ref = "main";
|
|
||||||
rev = "83cc0476cb11ea0da33dacd4c6354ab192de6fe6";
|
|
||||||
};
|
|
||||||
|
|
||||||
deps = with goProto; [
|
|
||||||
proto
|
|
||||||
ptypes.any
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
goGrpc = external {
|
|
||||||
path = "google.golang.org/grpc";
|
|
||||||
deps = ([
|
|
||||||
xnet.trace
|
|
||||||
xnet.http2
|
|
||||||
xsys.unix
|
|
||||||
xnet.http2.hpack
|
|
||||||
genproto.googleapis.rpc.status
|
|
||||||
] ++ (with goProto; [
|
|
||||||
proto
|
|
||||||
ptypes
|
|
||||||
ptypes.duration
|
|
||||||
ptypes.timestamp
|
|
||||||
]));
|
|
||||||
|
|
||||||
src = fetchGit {
|
|
||||||
url = "https://github.com/grpc/grpc-go";
|
|
||||||
rev = "d8e3da36ac481ef00e510ca119f6b68177713689";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue