From 675d5ba700f39b411619fae59f766571b440ae0a Mon Sep 17 00:00:00 2001 From: Arnout Engelen Date: Thu, 25 Mar 2021 11:41:51 +0100 Subject: [PATCH] buf: init at 0.40.0 --- pkgs/development/tools/buf/default.nix | 36 +++++++++++++++++++ .../buf/skip_test_requiring_network.patch | 15 ++++++++ pkgs/top-level/all-packages.nix | 2 ++ 3 files changed, 53 insertions(+) create mode 100644 pkgs/development/tools/buf/default.nix create mode 100644 pkgs/development/tools/buf/skip_test_requiring_network.patch diff --git a/pkgs/development/tools/buf/default.nix b/pkgs/development/tools/buf/default.nix new file mode 100644 index 000000000000..fc232d55da6d --- /dev/null +++ b/pkgs/development/tools/buf/default.nix @@ -0,0 +1,36 @@ +{ lib +, buildGoModule +, fetchFromGitHub +, protobuf +}: + +buildGoModule rec { + pname = "buf"; + version = "0.40.0"; + + src = fetchFromGitHub { + owner = "bufbuild"; + repo = pname; + rev = "v${version}"; + sha256 = "sha256-N6o+1cfer8rgKJ3+CL25axJSjGV/YSG1sLIHXJzsC6o="; + }; + + patches = [ + ./skip_test_requiring_network.patch + ]; + + preCheck = '' + export PATH=$PATH:$GOPATH/bin + ''; + + nativeBuildInputs = [ protobuf ]; + + vendorSha256 = "sha256-vl+WqtpegoAvylx/lcyfJk8DAOub8U4Lx3Pe3eW4M/E="; + + 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 ]; + }; +} diff --git a/pkgs/development/tools/buf/skip_test_requiring_network.patch b/pkgs/development/tools/buf/skip_test_requiring_network.patch new file mode 100644 index 000000000000..8d3e15c17ffb --- /dev/null +++ b/pkgs/development/tools/buf/skip_test_requiring_network.patch @@ -0,0 +1,15 @@ +diff --git a/internal/buf/internal/buftesting/buftesting.go b/internal/buf/internal/buftesting/buftesting.go +index dc8da0c..70ad299 100644 +--- a/internal/buf/internal/buftesting/buftesting.go ++++ b/internal/buf/internal/buftesting/buftesting.go +@@ -100,6 +100,10 @@ func RunActualProtoc( + + // GetGoogleapisDirPath gets the path to a clone of googleapis. + func GetGoogleapisDirPath(t *testing.T, buftestingDirPath string) string { ++ // Requires network access, which is not available during ++ // the nixpkgs sandboxed build ++ t.Skip() ++ + googleapisDirPath := filepath.Join(buftestingDirPath, testGoogleapisDirPath) + require.NoError( + t, diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3b7831d87960..0378c6bc9d7a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -166,6 +166,8 @@ in breakpad = callPackage ../development/misc/breakpad { }; + buf = callPackage ../development/tools/buf { }; + # Zip file format only allows times after year 1980, which makes e.g. Python wheel building fail with: # ValueError: ZIP does not support timestamps before 1980 ensureNewerSourcesForZipFilesHook = ensureNewerSourcesHook { year = "1980"; };