c594a97518
GitOrigin-RevId: 301aada7a64812853f2e2634a530ef5d34505048
78 lines
2 KiB
Nix
78 lines
2 KiB
Nix
{ lib
|
|
, buildGoModule
|
|
, fetchFromGitHub
|
|
, protobuf
|
|
, git
|
|
, testers
|
|
, buf
|
|
, installShellFiles
|
|
}:
|
|
|
|
buildGoModule rec {
|
|
pname = "buf";
|
|
version = "1.9.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "bufbuild";
|
|
repo = pname;
|
|
rev = "v${version}";
|
|
sha256 = "sha256-KnG1FUdC8xpW/wI4E8+RzO0StKF+N7Wx1jTWNm4302M=";
|
|
};
|
|
|
|
vendorSha256 = "sha256-e/hkJoQ1GkSl4mhhgYVB4POult87DzWOXRLGyDVP+M0=";
|
|
|
|
patches = [
|
|
# Skip a test that requires networking to be available to work.
|
|
./skip_test_requiring_network.patch
|
|
# Skip TestWorkspaceGit which requires .git and commits.
|
|
./skip_test_requiring_dotgit.patch
|
|
];
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
ldflags = [ "-s" "-w" ];
|
|
|
|
checkInputs = [
|
|
git # Required for TestGitCloner
|
|
protobuf # Required for buftesting.GetProtocFilePaths
|
|
];
|
|
|
|
preCheck = ''
|
|
# The tests need access to some of the built utilities
|
|
export PATH="$PATH:$GOPATH/bin"
|
|
# To skip TestCloneBranchAndRefToBucket
|
|
export CI=true
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
# Binaries
|
|
# Only install required binaries, don't install testing binaries
|
|
for FILE in buf protoc-gen-buf-breaking protoc-gen-buf-lint; do
|
|
install -D -m 555 -t $out/bin $GOPATH/bin/$FILE
|
|
done
|
|
|
|
# Completions
|
|
installShellCompletion --cmd buf \
|
|
--bash <($GOPATH/bin/buf completion bash) \
|
|
--fish <($GOPATH/bin/buf completion fish) \
|
|
--zsh <($GOPATH/bin/buf completion zsh)
|
|
|
|
# Man Pages
|
|
mkdir man && $GOPATH/bin/buf manpages man
|
|
installManPage man/*
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
passthru.tests.version = testers.testVersion { package = buf; };
|
|
|
|
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";
|
|
license = licenses.asl20;
|
|
maintainers = with maintainers; [ raboof jk lrewega ];
|
|
};
|
|
}
|