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

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

83 lines
2.0 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";
2022-04-22 07:01:59 +00:00
version = "1.4.0";
2021-03-25 10:41:51 +00:00
src = fetchFromGitHub {
owner = "bufbuild";
repo = pname;
rev = "v${version}";
2022-04-22 07:01:59 +00:00
sha256 = "sha256-cKb9pZYEsO1thgtl/8XFJHpNrO6P3OR8Lox/Gf9ccYk=";
2021-03-25 10:41:51 +00:00
};
2022-02-18 02:51:22 +00:00
2022-04-22 07:01:59 +00:00
vendorSha256 = "sha256-zXLvKEdiIFnmwWQBgbJHCEBe2i7FobgeUOnA3LvHl8w=";
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
];
2022-02-18 02:51:22 +00:00
nativeBuildInputs = [ installShellFiles ];
ldflags = [ "-s" "-w" ];
2022-02-18 02:51:22 +00:00
checkInputs = [
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"
# To skip TestCloneBranchAndRefToBucket
export CI=true
2021-03-25 10:41:51 +00:00
'';
installPhase = ''
runHook preInstall
2022-02-03 03:03:15 +00:00
# Binaries
mkdir -p "$out/bin"
# Only install required binaries, don't install testing binaries
for FILE in \
"buf" \
"protoc-gen-buf-breaking" \
2021-10-13 18:04:06 +00:00
"protoc-gen-buf-lint"; do
cp "$GOPATH/bin/$FILE" "$out/bin/"
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;
2021-10-13 18:04:06 +00:00
maintainers = with maintainers; [ raboof jk lrewega ];
2021-03-25 10:41:51 +00:00
};
}