summary refs log tree commit diff
path: root/pkgs/development/tools/buf/default.nix
blob: fb515841c7f230e9385a5d61fb719d93568c7789 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ lib
, buildGoModule
, fetchFromGitHub
, protobuf
, git
}:

buildGoModule rec {
  pname = "buf";
  version = "0.46.0";

  src = fetchFromGitHub {
    owner = "bufbuild";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-5mjk31HuPNO/RhmMhIm3dAZAED/Kk33ObjC8KbPKRxk=";
    leaveDotGit = true; # Required by TestWorkspaceGit
  };
  vendorSha256 = "sha256-K8UZDEhAvD292RCEDKfY9PdZGS389vLF3oukcBndUF4=";

  patches = [
    # Skip a test that requires networking to be available to work.
    ./skip_test_requiring_network.patch
  ];

  nativeBuildInputs = [ protobuf ];
  checkInputs = [ git ];

  ldflags = [ "-s" "-w" ];

  preCheck = ''
    export PATH=$PATH:$GOPATH/bin
    # To skip TestCloneBranchAndRefToBucket
    export CI=true
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p "$out/bin"
    dir="$GOPATH/bin"
    # Only install required binaries, don't install testing binaries
    for file in \
      "buf" \
      "protoc-gen-buf-breaking" \
      "protoc-gen-buf-lint" \
      "protoc-gen-buf-check-breaking" \
      "protoc-gen-buf-check-lint"; do
      cp "$dir/$file" "$out/bin/"
    done

    runHook postInstall
  '';

  meta = with lib; {
    description = "Create consistent Protobuf APIs that preserve compatibility and comply with design best-practices";
    homepage = "https://buf.build";
    license = licenses.asl20;
    maintainers = with maintainers; [ raboof ];
  };
}