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

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

79 lines
1.9 KiB
Nix
Raw Normal View History

2021-03-25 11:41:51 +01:00
{ lib
, buildGoModule
, fetchFromGitHub
, protobuf
, git
, testers
, buf
2022-02-03 04:03:15 +01:00
, installShellFiles
2021-03-25 11:41:51 +01:00
}:
buildGoModule rec {
pname = "buf";
2023-01-13 13:30:57 +01:00
version = "1.12.0";
2021-03-25 11:41:51 +01:00
src = fetchFromGitHub {
owner = "bufbuild";
repo = pname;
rev = "v${version}";
2023-01-13 13:30:57 +01:00
hash = "sha256-tEeAr1QSec1Sayfg2/erk5u6wBZDodZIMYq9MaU7ATA=";
2021-03-25 11:41:51 +01:00
};
2022-02-18 03:51:22 +01:00
2023-01-13 13:30:57 +01:00
vendorHash = "sha256-FCAxqyacDdt3mR628/sguvrBx+nG10648XqF5hA8z+s=";
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
# Skip TestWorkspaceGit which requires .git and commits.
./skip_test_requiring_dotgit.patch
2021-03-25 11:41:51 +01:00
];
2022-02-18 03:51:22 +01:00
nativeBuildInputs = [ installShellFiles ];
ldflags = [ "-s" "-w" ];
2022-02-18 03:51:22 +01:00
checkInputs = [
git # Required for TestGitCloner
protobuf # Required for buftesting.GetProtocFilePaths
];
2021-03-25 11:41:51 +01: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 11:41:51 +01:00
'';
installPhase = ''
runHook preInstall
2022-02-03 04:03:15 +01:00
# Binaries
# Only install required binaries, don't install testing binaries
2022-06-02 12:09:10 +02: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 11:41:51 +01:00
2022-02-03 04:03:15 +01:00
# Completions
installShellCompletion --cmd buf \
2022-02-18 03:51:22 +01:00
--bash <($GOPATH/bin/buf completion bash) \
--fish <($GOPATH/bin/buf completion fish) \
--zsh <($GOPATH/bin/buf completion zsh)
2022-02-03 04:03:15 +01:00
# Man Pages
mkdir man && $GOPATH/bin/buf manpages man
installManPage man/*
runHook postInstall
'';
2021-03-25 11:41:51 +01:00
passthru.tests.version = testers.testVersion { package = buf; };
2021-03-25 11:41:51 +01: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 11:41:51 +01:00
license = licenses.asl20;
maintainers = with maintainers; [ jk lrewega ];
2021-03-25 11:41:51 +01:00
};
}