summary refs log tree commit diff
path: root/pkgs/development/libraries/protobuf
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/protobuf')
-rw-r--r--pkgs/development/libraries/protobuf/21.nix6
-rw-r--r--pkgs/development/libraries/protobuf/23.nix6
-rw-r--r--pkgs/development/libraries/protobuf/24.nix6
-rw-r--r--pkgs/development/libraries/protobuf/3.19.nix6
-rw-r--r--pkgs/development/libraries/protobuf/3.21.nix6
-rw-r--r--pkgs/development/libraries/protobuf/3.23.nix6
-rw-r--r--pkgs/development/libraries/protobuf/3.24.nix6
-rw-r--r--pkgs/development/libraries/protobuf/generic-v3-cmake.nix118
-rw-r--r--pkgs/development/libraries/protobuf/generic.nix114
9 files changed, 132 insertions, 142 deletions
diff --git a/pkgs/development/libraries/protobuf/21.nix b/pkgs/development/libraries/protobuf/21.nix
new file mode 100644
index 00000000000..09a8c81b3d1
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/21.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix ({
+  version = "21.12";
+  hash = "sha256-VZQEFHq17UsTH5CZZOcJBKiScGV2xPJ/e6gkkVliRCU=";
+} // args)
diff --git a/pkgs/development/libraries/protobuf/23.nix b/pkgs/development/libraries/protobuf/23.nix
new file mode 100644
index 00000000000..abb2cc2f446
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/23.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix ({
+  version = "23.4";
+  hash = "sha256-eI+mrsZAOLEsdyTC3B+K+GjD3r16CmPx1KJ2KhCwFdg=";
+} // args)
diff --git a/pkgs/development/libraries/protobuf/24.nix b/pkgs/development/libraries/protobuf/24.nix
new file mode 100644
index 00000000000..6741b8afe52
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/24.nix
@@ -0,0 +1,6 @@
+{ callPackage, ... } @ args:
+
+callPackage ./generic.nix ({
+  version = "24.4";
+  hash = "sha256-I+Xtq4GOs++f/RlVff9MZuolXrMLmrZ2z6mkBayqQ2s=";
+} // args)
diff --git a/pkgs/development/libraries/protobuf/3.19.nix b/pkgs/development/libraries/protobuf/3.19.nix
deleted file mode 100644
index 7ee378d8ed3..00000000000
--- a/pkgs/development/libraries/protobuf/3.19.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ callPackage, ... } @ args:
-
-callPackage ./generic-v3.nix ({
-  version = "3.19.6";
-  sha256 = "sha256-+ul9F8tyrwk2p25Dd9ragqwpYzdxdeGjpXhLAwKYWfM=";
-} // args)
diff --git a/pkgs/development/libraries/protobuf/3.21.nix b/pkgs/development/libraries/protobuf/3.21.nix
deleted file mode 100644
index fe85be8cf02..00000000000
--- a/pkgs/development/libraries/protobuf/3.21.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ callPackage, ... } @ args:
-
-callPackage ./generic-v3-cmake.nix ({
-  version = "3.21.12";
-  sha256 = "sha256-VZQEFHq17UsTH5CZZOcJBKiScGV2xPJ/e6gkkVliRCU=";
-} // args)
diff --git a/pkgs/development/libraries/protobuf/3.23.nix b/pkgs/development/libraries/protobuf/3.23.nix
deleted file mode 100644
index 2d658d57419..00000000000
--- a/pkgs/development/libraries/protobuf/3.23.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ callPackage, ... } @ args:
-
-callPackage ./generic-v3-cmake.nix ({
-  version = "3.23.4";
-  sha256 = "sha256-eI+mrsZAOLEsdyTC3B+K+GjD3r16CmPx1KJ2KhCwFdg=";
-} // args)
diff --git a/pkgs/development/libraries/protobuf/3.24.nix b/pkgs/development/libraries/protobuf/3.24.nix
deleted file mode 100644
index 2deb155444e..00000000000
--- a/pkgs/development/libraries/protobuf/3.24.nix
+++ /dev/null
@@ -1,6 +0,0 @@
-{ callPackage, ... } @ args:
-
-callPackage ./generic-v3-cmake.nix ({
-  version = "3.24.2";
-  sha256 = "sha256-yVLszyVtsz1CCzeOkioL4O3mWTFKKVBUyOhwDbC5UqE=";
-} // args)
diff --git a/pkgs/development/libraries/protobuf/generic-v3-cmake.nix b/pkgs/development/libraries/protobuf/generic-v3-cmake.nix
deleted file mode 100644
index 384d2d0decb..00000000000
--- a/pkgs/development/libraries/protobuf/generic-v3-cmake.nix
+++ /dev/null
@@ -1,118 +0,0 @@
-# The cmake version of this build is meant to enable both cmake and .pc being exported
-# this is important because grpc exports a .cmake file which also expects for protobuf
-# to have been exported through cmake as well.
-{ lib
-, stdenv
-, abseil-cpp
-, buildPackages
-, cmake
-, fetchFromGitHub
-, fetchpatch
-, gtest
-, zlib
-, version
-, sha256
-
-# downstream dependencies
-, python3
-
-, ...
-}:
-
-let
-  self = stdenv.mkDerivation {
-    pname = "protobuf";
-    inherit version;
-
-    src = fetchFromGitHub {
-      owner = "protocolbuffers";
-      repo = "protobuf";
-      rev = "v${version}";
-      inherit sha256;
-    };
-
-    # re-create submodule logic
-    postPatch = ''
-      rm -rf gmock
-      cp -r ${gtest.src}/googlemock third_party/gmock
-      cp -r ${gtest.src}/googletest third_party/
-      chmod -R a+w third_party/
-
-      ln -s ../googletest third_party/gmock/gtest
-      ln -s ../gmock third_party/googletest/googlemock
-      ln -s $(pwd)/third_party/googletest third_party/googletest/googletest
-    '' + lib.optionalString stdenv.isDarwin ''
-      substituteInPlace src/google/protobuf/testing/googletest.cc \
-        --replace 'tmpnam(b)' '"'$TMPDIR'/foo"'
-    '';
-
-    patches = lib.optionals (lib.versionOlder version "3.22") [
-      # fix protobuf-targets.cmake installation paths, and allow for CMAKE_INSTALL_LIBDIR to be absolute
-      # https://github.com/protocolbuffers/protobuf/pull/10090
-      (fetchpatch {
-        url = "https://github.com/protocolbuffers/protobuf/commit/a7324f88e92bc16b57f3683403b6c993bf68070b.patch";
-        sha256 = "sha256-SmwaUjOjjZulg/wgNmR/F5b8rhYA2wkKAjHIOxjcQdQ=";
-      })
-    ] ++ lib.optionals stdenv.hostPlatform.isStatic [
-      ./static-executables-have-no-rpath.patch
-    ];
-
-    nativeBuildInputs = let
-      protobufVersion = "${lib.versions.major version}_${lib.versions.minor version}";
-    in [
-      cmake
-    ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
-      # protoc of the same version must be available for build. For non-cross builds, it's able to
-      # re-use the executable generated as part of the build
-      buildPackages."protobuf${protobufVersion}"
-    ];
-
-    buildInputs = [
-      zlib
-    ];
-
-    propagatedBuildInputs = [
-      abseil-cpp
-    ];
-
-    cmakeDir = if lib.versionOlder version "3.22" then "../cmake" else null;
-    cmakeFlags = [
-      "-Dprotobuf_ABSL_PROVIDER=package"
-    ] ++ lib.optionals (!stdenv.targetPlatform.isStatic) [
-      "-Dprotobuf_BUILD_SHARED_LIBS=ON"
-    ]
-    # Tests fail to build on 32-bit platforms; fixed in 3.22
-    # https://github.com/protocolbuffers/protobuf/issues/10418
-    ++ lib.optional
-      (stdenv.targetPlatform.is32bit && lib.versionOlder version "3.22")
-      "-Dprotobuf_BUILD_TESTS=OFF";
-
-    # unfortunately the shared libraries have yet to been patched by nix, thus tests will fail
-    doCheck = false;
-
-    passthru = {
-      tests = {
-        pythonProtobuf = python3.pkgs.protobuf.override(_: {
-          protobuf = self;
-        });
-      };
-
-      inherit abseil-cpp;
-    };
-
-    meta = {
-      description = "Google's data interchange format";
-      longDescription = ''
-        Protocol Buffers are a way of encoding structured data in an efficient
-        yet extensible format. Google uses Protocol Buffers for almost all of
-        its internal RPC protocols and file formats.
-      '';
-      license = lib.licenses.bsd3;
-      platforms = lib.platforms.unix;
-      homepage = "https://developers.google.com/protocol-buffers/";
-      maintainers = with lib.maintainers; [ jonringer ];
-      mainProgram = "protoc";
-    };
-  };
-in
-  self
diff --git a/pkgs/development/libraries/protobuf/generic.nix b/pkgs/development/libraries/protobuf/generic.nix
new file mode 100644
index 00000000000..cf00d1d50be
--- /dev/null
+++ b/pkgs/development/libraries/protobuf/generic.nix
@@ -0,0 +1,114 @@
+# The cmake version of this build is meant to enable both cmake and .pc being exported
+# this is important because grpc exports a .cmake file which also expects for protobuf
+# to have been exported through cmake as well.
+{ lib
+, stdenv
+, abseil-cpp
+, buildPackages
+, cmake
+, fetchFromGitHub
+, fetchpatch
+, gtest
+, zlib
+, version
+, hash
+
+  # downstream dependencies
+, python3
+, grpc
+, enableShared ? !stdenv.hostPlatform.isStatic
+
+, ...
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "protobuf";
+  inherit version;
+
+  src = fetchFromGitHub {
+    owner = "protocolbuffers";
+    repo = "protobuf";
+    rev = "v${version}";
+    inherit hash;
+  };
+
+  postPatch = lib.optionalString stdenv.isDarwin ''
+    substituteInPlace src/google/protobuf/testing/googletest.cc \
+      --replace 'tmpnam(b)' '"'$TMPDIR'/foo"'
+  '';
+
+  patches = lib.optionals (lib.versionOlder version "22") [
+    # fix protobuf-targets.cmake installation paths, and allow for CMAKE_INSTALL_LIBDIR to be absolute
+    # https://github.com/protocolbuffers/protobuf/pull/10090
+    (fetchpatch {
+      url = "https://github.com/protocolbuffers/protobuf/commit/a7324f88e92bc16b57f3683403b6c993bf68070b.patch";
+      hash = "sha256-SmwaUjOjjZulg/wgNmR/F5b8rhYA2wkKAjHIOxjcQdQ=";
+    })
+  ] ++ lib.optionals stdenv.hostPlatform.isStatic [
+    ./static-executables-have-no-rpath.patch
+  ];
+
+  nativeBuildInputs = [
+    cmake
+  ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
+    # protoc of the same version must be available for build. For non-cross builds, it's able to
+    # re-use the executable generated as part of the build
+    buildPackages."protobuf_${lib.versions.major version}"
+  ];
+
+  buildInputs = [
+    gtest
+    zlib
+  ];
+
+  propagatedBuildInputs = [
+    abseil-cpp
+  ];
+
+  strictDeps = true;
+
+  cmakeDir = if lib.versionOlder version "22" then "../cmake" else null;
+  cmakeFlags = [
+    "-Dprotobuf_USE_EXTERNAL_GTEST=ON"
+    "-Dprotobuf_ABSL_PROVIDER=package"
+  ] ++ lib.optionals enableShared [
+    "-Dprotobuf_BUILD_SHARED_LIBS=ON"
+  ]
+  # Tests fail to build on 32-bit platforms; fixed in 22.x
+  # https://github.com/protocolbuffers/protobuf/issues/10418
+  ++ lib.optionals (stdenv.hostPlatform.is32bit && lib.versionOlder version "22") [
+    "-Dprotobuf_BUILD_TESTS=OFF"
+  ];
+
+  # FIXME: investigate.  24.x and 23.x have different errors.
+  # At least some of it is not reproduced on some other machine; example:
+  # https://hydra.nixos.org/build/235677717/nixlog/4/tail
+  # Also AnyTest.TestPackFromSerializationExceedsSizeLimit fails on 32-bit platforms
+  # https://github.com/protocolbuffers/protobuf/issues/8460
+  doCheck = !(stdenv.isDarwin && lib.versionAtLeast version "23") && !stdenv.hostPlatform.is32bit;
+
+  passthru = {
+    tests = {
+      pythonProtobuf = python3.pkgs.protobuf.override (_: {
+        protobuf = finalAttrs.finalPackage;
+      });
+      inherit grpc;
+    };
+
+    inherit abseil-cpp;
+  };
+
+  meta = {
+    description = "Google's data interchange format";
+    longDescription = ''
+      Protocol Buffers are a way of encoding structured data in an efficient
+      yet extensible format. Google uses Protocol Buffers for almost all of
+      its internal RPC protocols and file formats.
+    '';
+    license = lib.licenses.bsd3;
+    platforms = lib.platforms.all;
+    homepage = "https://protobuf.dev/";
+    maintainers = with lib.maintainers; [ jonringer ];
+    mainProgram = "protoc";
+  };
+})