From 48038eb32806a77ad3d21f4aa8c8d37197cfbc78 Mon Sep 17 00:00:00 2001
From: Johannes Schleifenbaum <johannes@js-webcoding.de>
Date: Fri, 15 Jan 2021 14:08:54 +0100
Subject: [PATCH] phpExtensions.protobuf: fix build with PHP 8

---
 .../php-packages/protobuf/default.nix         | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/pkgs/development/php-packages/protobuf/default.nix b/pkgs/development/php-packages/protobuf/default.nix
index 10b045897373..e2ef068120d7 100644
--- a/pkgs/development/php-packages/protobuf/default.nix
+++ b/pkgs/development/php-packages/protobuf/default.nix
@@ -1,4 +1,4 @@
-{ buildPecl, lib, pcre' }:
+{ buildPecl, lib, pcre', fetchpatch }:
 
 buildPecl {
   pname = "protobuf";
@@ -8,6 +8,23 @@ buildPecl {
 
   buildInputs = [ pcre' ];
 
+  patches = [
+    # TODO: remove with next update
+    (fetchpatch {
+      url = "https://github.com/protocolbuffers/protobuf/commit/823f351448f7c432bed40b89ee3309e0a94c1855.patch";
+      sha256 = "sha256-ozHtO8s9zvmh/+wBEge3Yn3n0pbpR3dAojJcuAg/G3s=";
+      stripLen = 4;
+      includes = [
+        "array.c"
+        "def.c"
+        "map.c"
+        "message.c"
+        "protobuf.h"
+        "wkt.inc"
+      ];
+    })
+  ];
+
   meta = with lib; {
     description = ''
       Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.