3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/tools/buf/default.nix

73 lines
1.8 KiB
Nix
Raw Normal View History

2021-03-25 10:41:51 +00:00
{ lib
, buildGoModule
, fetchFromGitHub
, protobuf
, git
2021-03-25 10:41:51 +00:00
}:
buildGoModule rec {
pname = "buf";
2021-08-14 03:21:17 +01:00
version = "0.50.0";
2021-03-25 10:41:51 +00:00
src = fetchFromGitHub {
owner = "bufbuild";
repo = pname;
rev = "v${version}";
2021-08-14 03:21:17 +01:00
sha256 = "sha256-Kg3p6BsYrIGn16VQ87TQwa7B+YVEq6oCSd3Je2A6NC8=";
2021-03-25 10:41:51 +00:00
};
2021-08-14 03:21:17 +01:00
vendorSha256 = "sha256-0vvDzs4LliEm202tScmzL+riL3FqHdvawhzU0lPkRew=";
2021-03-25 10:41:51 +00:00
patches = [
# Skip a test that requires networking to be available to work.
2021-03-25 10:41:51 +00:00
./skip_test_requiring_network.patch
# Skip TestWorkspaceGit which requires .git and commits.
./skip_test_requiring_dotgit.patch
2021-03-25 10:41:51 +00:00
];
nativeBuildInputs = [ protobuf ];
# Required for TestGitCloner
checkInputs = [ git ];
ldflags = [ "-s" "-w" ];
2021-03-25 10:41:51 +00:00
preCheck = ''
# The tests need access to some of the built utilities
export PATH="$PATH:$GOPATH/bin"
# To skip TestCloneBranchAndRefToBucket
export CI=true
2021-03-25 10:41:51 +00:00
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/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 "$GOPATH/bin/$FILE" "$out/bin/"
done
2021-03-25 10:41:51 +00:00
runHook postInstall
'';
2021-03-25 10:41:51 +00:00
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/buf --help
$out/bin/buf --version 2>&1 | grep "${version}"
runHook postInstallCheck
'';
2021-03-25 10:41:51 +00:00
meta = with lib; {
homepage = "https://buf.build";
changelog = "https://github.com/bufbuild/buf/releases/tag/v${version}";
description = "Create consistent Protobuf APIs that preserve compatibility and comply with design best-practices";
2021-03-25 10:41:51 +00:00
license = licenses.asl20;
maintainers = with maintainers; [ raboof jk ];
2021-03-25 10:41:51 +00:00
};
}