2021-03-20 04:20:00 +00:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, protobuf
|
2021-06-28 23:13:55 +00:00
|
|
|
, git
|
2022-04-27 09:35:20 +00:00
|
|
|
, testers
|
2021-08-18 13:19:15 +00:00
|
|
|
, buf
|
2022-02-10 20:34:41 +00:00
|
|
|
, installShellFiles
|
2021-03-20 04:20:00 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "buf";
|
2023-07-15 17:15:38 +00:00
|
|
|
version = "1.24.0";
|
2021-03-20 04:20:00 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bufbuild";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2023-07-15 17:15:38 +00:00
|
|
|
hash = "sha256-DMZYjtIuN8b03UOAEtz32+Cj2MaE46v2k0IHT7YiZfk=";
|
2021-03-20 04:20:00 +00:00
|
|
|
};
|
2022-02-20 05:27:41 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
vendorHash = "sha256-uBM5r3cT0c4NUOfWaqkxRJ06p2GtOwvSOQfvP77ivTA=";
|
2021-03-20 04:20:00 +00:00
|
|
|
|
|
|
|
patches = [
|
2021-07-14 22:03:04 +00:00
|
|
|
# Skip a test that requires networking to be available to work.
|
2021-03-20 04:20:00 +00:00
|
|
|
./skip_test_requiring_network.patch
|
|
|
|
];
|
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
2021-06-28 23:13:55 +00:00
|
|
|
|
|
|
|
ldflags = [ "-s" "-w" ];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [
|
2022-02-20 05:27:41 +00:00
|
|
|
git # Required for TestGitCloner
|
|
|
|
protobuf # Required for buftesting.GetProtocFilePaths
|
|
|
|
];
|
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
preCheck = ''
|
2021-08-11 14:56:57 +00:00
|
|
|
# The tests need access to some of the built utilities
|
|
|
|
export PATH="$PATH:$GOPATH/bin"
|
2021-03-20 04:20:00 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-24 00:07:29 +00:00
|
|
|
# Allow tests that bind or connect to localhost on macOS.
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# Binaries
|
2021-06-28 23:13:55 +00:00
|
|
|
# Only install required binaries, don't install testing binaries
|
2022-06-16 17:23:12 +00:00
|
|
|
for FILE in buf protoc-gen-buf-breaking protoc-gen-buf-lint; do
|
|
|
|
install -D -m 555 -t $out/bin $GOPATH/bin/$FILE
|
2021-06-28 23:13:55 +00:00
|
|
|
done
|
2021-03-20 04:20:00 +00:00
|
|
|
|
2022-02-10 20:34:41 +00:00
|
|
|
# Completions
|
|
|
|
installShellCompletion --cmd buf \
|
2022-02-20 05:27:41 +00:00
|
|
|
--bash <($GOPATH/bin/buf completion bash) \
|
|
|
|
--fish <($GOPATH/bin/buf completion fish) \
|
|
|
|
--zsh <($GOPATH/bin/buf completion zsh)
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
# Man Pages
|
|
|
|
mkdir man && $GOPATH/bin/buf manpages man
|
|
|
|
installManPage man/*
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2021-03-20 04:20:00 +00:00
|
|
|
|
2022-04-27 09:35:20 +00:00
|
|
|
passthru.tests.version = testers.testVersion { package = buf; };
|
2021-08-11 14:56:57 +00:00
|
|
|
|
2021-03-20 04:20:00 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://buf.build";
|
2021-08-11 14:56:57 +00:00
|
|
|
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-20 04:20:00 +00:00
|
|
|
license = licenses.asl20;
|
2022-11-21 17:40:18 +00:00
|
|
|
maintainers = with maintainers; [ jk lrewega ];
|
2021-03-20 04:20:00 +00:00
|
|
|
};
|
|
|
|
}
|