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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
1.9 KiB
Nix
Raw Normal View History

2021-03-25 10:41:51 +00:00
{ lib
, buildGoModule
, fetchFromGitHub
, protobuf
, git
, testers
, buf
2022-02-03 03:03:15 +00:00
, installShellFiles
2021-03-25 10:41:51 +00:00
}:
buildGoModule rec {
pname = "buf";
2023-08-10 02:14:17 +00:00
version = "1.26.1";
2021-03-25 10:41:51 +00:00
src = fetchFromGitHub {
owner = "bufbuild";
repo = pname;
rev = "v${version}";
2023-08-10 02:14:17 +00:00
hash = "sha256-e00o3G66GCJyA3flqRa+J1yQVBVusBrEOJrL9viKtlM=";
2021-03-25 10:41:51 +00:00
};
2022-02-18 02:51:22 +00:00
2023-08-10 02:14:17 +00:00
vendorHash = "sha256-7RVYD0r3nqb0yLmKu9zzpQNiVDVBJGG1BiVb6J+VR9k=";
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
];
2022-02-18 02:51:22 +00:00
nativeBuildInputs = [ installShellFiles ];
ldflags = [ "-s" "-w" ];
nativeCheckInputs = [
2022-02-18 02:51:22 +00:00
git # Required for TestGitCloner
protobuf # Required for buftesting.GetProtocFilePaths
];
2021-03-25 10:41:51 +00:00
preCheck = ''
# The tests need access to some of the built utilities
export PATH="$PATH:$GOPATH/bin"
2021-03-25 10:41:51 +00:00
'';
# Allow tests that bind or connect to localhost on macOS.
__darwinAllowLocalNetworking = true;
installPhase = ''
runHook preInstall
2022-02-03 03:03:15 +00:00
# Binaries
# Only install required binaries, don't install testing binaries
2022-06-02 10:09:10 +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
done
2021-03-25 10:41:51 +00:00
2022-02-03 03:03:15 +00:00
# Completions
installShellCompletion --cmd buf \
2022-02-18 02:51:22 +00:00
--bash <($GOPATH/bin/buf completion bash) \
--fish <($GOPATH/bin/buf completion fish) \
--zsh <($GOPATH/bin/buf completion zsh)
2022-02-03 03:03:15 +00:00
# Man Pages
mkdir man && $GOPATH/bin/buf manpages man
installManPage man/*
runHook postInstall
'';
2021-03-25 10:41:51 +00:00
passthru.tests.version = testers.testVersion { package = buf; };
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; [ jk lrewega ];
2021-03-25 10:41:51 +00:00
};
}