python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / development / tools / buf / default.nix
blob5acd05013faf5ffb9702b39d2a669d7325c03e95
1 { lib
2 , buildGoModule
3 , fetchFromGitHub
4 , fetchpatch
5 , protobuf
6 , git
7 , testers
8 , buf
9 , installShellFiles
12 buildGoModule rec {
13   pname = "buf";
14   version = "1.9.0";
16   src = fetchFromGitHub {
17     owner = "bufbuild";
18     repo = pname;
19     rev = "v${version}";
20     sha256 = "sha256-KnG1FUdC8xpW/wI4E8+RzO0StKF+N7Wx1jTWNm4302M=";
21   };
23   vendorSha256 = "sha256-e/hkJoQ1GkSl4mhhgYVB4POult87DzWOXRLGyDVP+M0=";
25   patches = [
26     # Skip a test that requires networking to be available to work.
27     ./skip_test_requiring_network.patch
28     # Skip TestWorkspaceGit which requires .git and commits.
29     ./skip_test_requiring_dotgit.patch
30     # Remove reliance of tests on file protocol which is disabled in git by default now
31     # Rebased upstream change https://github.com/bufbuild/buf/commit/bcaa77f8bbb8f6c198154c7c8d53596da4506dab
32     ./buf-tests-dont-use-file-transport.patch
33     # Make TestCyclicImport tests deterministic (see https://github.com/bufbuild/buf/pull/1551)
34     (fetchpatch {
35       url = "https://github.com/bufbuild/buf/commit/75b5ef4c84f5953002dff95a1c66cb82b0e3b06f.patch";
36       sha256 = "sha256-pKF3VXkzttsTTT2r/Z37ug9nnu8gRdkfmv/aTOhAJpw=";
37     })
38     # Make TestDuplicateSyntheticOneofs check deterministic (see https://github.com/bufbuild/buf/pull/1579)
39     (fetchpatch {
40       url = "https://github.com/bufbuild/buf/commit/9e72aa314e6f02b36793caa5f6068394cbdcb98c.patch";
41       sha256 = "sha256-6NEF3sP1EQ6cQxkH2xRyHxAD0OrXBlQQa05rLK998wo=";
42     })
43   ];
45   nativeBuildInputs = [ installShellFiles ];
47   ldflags = [ "-s" "-w" ];
49   checkInputs = [
50     git # Required for TestGitCloner
51     protobuf # Required for buftesting.GetProtocFilePaths
52   ];
54   preCheck = ''
55     # The tests need access to some of the built utilities
56     export PATH="$PATH:$GOPATH/bin"
57     # To skip TestCloneBranchAndRefToBucket
58     export CI=true
59   '';
61   installPhase = ''
62     runHook preInstall
64     # Binaries
65     # Only install required binaries, don't install testing binaries
66     for FILE in buf protoc-gen-buf-breaking protoc-gen-buf-lint; do
67       install -D -m 555 -t $out/bin $GOPATH/bin/$FILE
68     done
70     # Completions
71     installShellCompletion --cmd buf \
72       --bash <($GOPATH/bin/buf completion bash) \
73       --fish <($GOPATH/bin/buf completion fish) \
74       --zsh <($GOPATH/bin/buf completion zsh)
76     # Man Pages
77     mkdir man && $GOPATH/bin/buf manpages man
78     installManPage man/*
80     runHook postInstall
81   '';
83   passthru.tests.version = testers.testVersion { package = buf; };
85   meta = with lib; {
86     homepage = "https://buf.build";
87     changelog = "https://github.com/bufbuild/buf/releases/tag/v${version}";
88     description = "Create consistent Protobuf APIs that preserve compatibility and comply with design best-practices";
89     license = licenses.asl20;
90     maintainers = with maintainers; [ jk lrewega ];
91   };