nixpkgs/pkgs/development/tools/buf/default.nix

62 lines
1.4 KiB
Nix
Raw Normal View History

2021-03-25 11:41:51 +01:00
{ lib
, buildGoModule
, fetchFromGitHub
, protobuf
, git
2021-03-25 11:41:51 +01:00
}:
buildGoModule rec {
pname = "buf";
2021-07-13 13:34:38 +02:00
version = "0.44.0";
2021-03-25 11:41:51 +01:00
src = fetchFromGitHub {
owner = "bufbuild";
repo = pname;
rev = "v${version}";
2021-07-13 13:34:38 +02:00
sha256 = "sha256-ZcZvsFw/l/7N8Yb4HG6w96ce9c4g4iiG/TcDoj8RYmA=";
leaveDotGit = true; # Required by TestWorkspaceGit
2021-03-25 11:41:51 +01:00
};
2021-07-13 13:34:38 +02:00
vendorSha256 = "sha256-g0wrHPeHFOL6KB0SUgBy2WK54Kttiks4cuYg8jf3N9g=";
2021-03-25 11:41:51 +01:00
patches = [
# Skip a test that requires networking to be available to work.
2021-03-25 11:41:51 +01:00
./skip_test_requiring_network.patch
];
nativeBuildInputs = [ protobuf ];
checkInputs = [ git ];
ldflags = [ "-s" "-w" ];
2021-03-25 11:41:51 +01:00
preCheck = ''
export PATH=$PATH:$GOPATH/bin
# To skip TestCloneBranchAndRefToBucket
export CI=true
2021-03-25 11:41:51 +01:00
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/bin"
dir="$GOPATH/bin"
# Only install required binaries, don't install testing binaries
for file in \
"buf" \
"protoc-gen-buf-breaking" \
"protoc-gen-buf-lint" \
"protoc-gen-buf-check-breaking" \
"protoc-gen-buf-check-lint"; do
cp "$dir/$file" "$out/bin/"
done
2021-03-25 11:41:51 +01:00
runHook postInstall
'';
2021-03-25 11:41:51 +01:00
meta = with lib; {
description = "Create consistent Protobuf APIs that preserve compatibility and comply with design best-practices";
homepage = "https://buf.build";
license = licenses.asl20;
maintainers = with maintainers; [ raboof ];
};
}