Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.11-beta 77 lines 1.9 kB view raw
1{ lib 2, buildGoModule 3, fetchFromGitHub 4, protobuf 5, git 6, testers 7, buf 8, installShellFiles 9}: 10 11buildGoModule rec { 12 pname = "buf"; 13 version = "1.27.0"; 14 15 src = fetchFromGitHub { 16 owner = "bufbuild"; 17 repo = pname; 18 rev = "v${version}"; 19 hash = "sha256-QBU04/w7Z8yaTzDqhiVcxC8xEuDpDJs7rNRpOtwodGg="; 20 }; 21 22 vendorHash = "sha256-4JSmn/TUojZjCQMZCgJic0y84VMP26J7uBybB5/BCoE="; 23 24 patches = [ 25 # Skip a test that requires networking to be available to work. 26 ./skip_test_requiring_network.patch 27 ]; 28 29 nativeBuildInputs = [ installShellFiles ]; 30 31 ldflags = [ "-s" "-w" ]; 32 33 nativeCheckInputs = [ 34 git # Required for TestGitCloner 35 protobuf # Required for buftesting.GetProtocFilePaths 36 ]; 37 38 preCheck = '' 39 # The tests need access to some of the built utilities 40 export PATH="$PATH:$GOPATH/bin" 41 ''; 42 43 # Allow tests that bind or connect to localhost on macOS. 44 __darwinAllowLocalNetworking = true; 45 46 installPhase = '' 47 runHook preInstall 48 49 # Binaries 50 # Only install required binaries, don't install testing binaries 51 for FILE in buf protoc-gen-buf-breaking protoc-gen-buf-lint; do 52 install -D -m 555 -t $out/bin $GOPATH/bin/$FILE 53 done 54 55 # Completions 56 installShellCompletion --cmd buf \ 57 --bash <($GOPATH/bin/buf completion bash) \ 58 --fish <($GOPATH/bin/buf completion fish) \ 59 --zsh <($GOPATH/bin/buf completion zsh) 60 61 # Man Pages 62 mkdir man && $GOPATH/bin/buf manpages man 63 installManPage man/* 64 65 runHook postInstall 66 ''; 67 68 passthru.tests.version = testers.testVersion { package = buf; }; 69 70 meta = with lib; { 71 homepage = "https://buf.build"; 72 changelog = "https://github.com/bufbuild/buf/releases/tag/v${version}"; 73 description = "Create consistent Protobuf APIs that preserve compatibility and comply with design best-practices"; 74 license = licenses.asl20; 75 maintainers = with maintainers; [ jk lrewega ]; 76 }; 77}