2021-03-25 10:41:51 +00:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchFromGitHub
|
|
|
|
, protobuf
|
2021-06-19 08:43:46 +00:00
|
|
|
, git
|
2021-08-14 08:11:33 +00:00
|
|
|
, testVersion
|
|
|
|
, buf
|
2022-02-03 03:03:15 +00:00
|
|
|
, installShellFiles
|
2021-03-25 10:41:51 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "buf";
|
2022-02-03 03:03:15 +00:00
|
|
|
version = "1.0.0-rc12";
|
2021-03-25 10:41:51 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bufbuild";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-02-03 03:03:15 +00:00
|
|
|
sha256 = "sha256-UqyWQdlCDTSjW348f87W7g2kwB5nzIOviSE5/1T1soY=";
|
2021-03-25 10:41:51 +00:00
|
|
|
};
|
2022-02-03 03:03:15 +00:00
|
|
|
vendorSha256 = "sha256-qBgGZTok3G0Pgku76uiV9bZperhiSNoWSrzxrHe4QXw=";
|
2021-03-25 10:41:51 +00:00
|
|
|
|
|
|
|
patches = [
|
2021-07-13 15:06:06 +00:00
|
|
|
# Skip a test that requires networking to be available to work.
|
2021-03-25 10:41:51 +00:00
|
|
|
./skip_test_requiring_network.patch
|
2021-08-11 09:29:52 +00:00
|
|
|
# Skip TestWorkspaceGit which requires .git and commits.
|
|
|
|
./skip_test_requiring_dotgit.patch
|
2021-03-25 10:41:51 +00:00
|
|
|
];
|
|
|
|
|
2022-02-03 03:03:15 +00:00
|
|
|
nativeBuildInputs = [ protobuf installShellFiles ];
|
2021-08-11 09:29:52 +00:00
|
|
|
# Required for TestGitCloner
|
2021-06-19 08:43:46 +00:00
|
|
|
checkInputs = [ git ];
|
|
|
|
|
|
|
|
ldflags = [ "-s" "-w" ];
|
|
|
|
|
2021-03-25 10:41:51 +00:00
|
|
|
preCheck = ''
|
2021-08-11 09:29:52 +00:00
|
|
|
# The tests need access to some of the built utilities
|
|
|
|
export PATH="$PATH:$GOPATH/bin"
|
2021-06-19 08:43:46 +00:00
|
|
|
# To skip TestCloneBranchAndRefToBucket
|
|
|
|
export CI=true
|
2021-03-25 10:41:51 +00:00
|
|
|
'';
|
|
|
|
|
2021-06-19 08:43:46 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2022-02-03 03:03:15 +00:00
|
|
|
# Binaries
|
2021-06-19 08:43:46 +00:00
|
|
|
mkdir -p "$out/bin"
|
|
|
|
# Only install required binaries, don't install testing binaries
|
2021-08-11 09:29:52 +00:00
|
|
|
for FILE in \
|
2021-06-19 08:43:46 +00:00
|
|
|
"buf" \
|
|
|
|
"protoc-gen-buf-breaking" \
|
2021-10-13 18:04:06 +00:00
|
|
|
"protoc-gen-buf-lint"; do
|
2021-08-11 09:29:52 +00:00
|
|
|
cp "$GOPATH/bin/$FILE" "$out/bin/"
|
2021-06-19 08:43:46 +00:00
|
|
|
done
|
2021-03-25 10:41:51 +00:00
|
|
|
|
2022-02-03 03:03:15 +00:00
|
|
|
# Completions
|
|
|
|
installShellCompletion --cmd buf \
|
|
|
|
--bash <($GOPATH/bin/buf bash-completion) \
|
|
|
|
--fish <($GOPATH/bin/buf fish-completion) \
|
|
|
|
--zsh <($GOPATH/bin/buf zsh-completion)
|
|
|
|
|
|
|
|
# Man Pages
|
|
|
|
mkdir man && $GOPATH/bin/buf manpages man
|
|
|
|
installManPage man/*
|
|
|
|
|
2021-06-19 08:43:46 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
2021-03-25 10:41:51 +00:00
|
|
|
|
2021-08-14 08:11:33 +00:00
|
|
|
passthru.tests.version = testVersion { package = buf; };
|
2021-08-11 09:29:52 +00:00
|
|
|
|
2021-03-25 10:41:51 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://buf.build";
|
2021-08-11 09:29:52 +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-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
|
|
|
};
|
|
|
|
}
|