From 6267a02d9c3980c105c8633ec5e7f43d27e7bb8a Mon Sep 17 00:00:00 2001
From: Bas van Dijk <v.dijk.bas@gmail.com>
Date: Thu, 20 Dec 2018 09:45:37 +0100
Subject: [PATCH] opencv4: fix OpenCV issue 13207

This is the same fix as for opencv3 in commit:
2572dd11accf701feeefd6fd4ee45be98cb47016
---
 pkgs/development/libraries/opencv/4.x.nix | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/pkgs/development/libraries/opencv/4.x.nix b/pkgs/development/libraries/opencv/4.x.nix
index 407070506ab..c90ed76b534 100644
--- a/pkgs/development/libraries/opencv/4.x.nix
+++ b/pkgs/development/libraries/opencv/4.x.nix
@@ -160,7 +160,15 @@ stdenv.mkDerivation rec {
     cp --no-preserve=mode -r "${contribSrc}/modules" "$NIX_BUILD_TOP/source/opencv_contrib"
   '';
 
-  patches =
+  patches = [
+    # https://github.com/opencv/opencv/pull/13232
+    # This also fixes the test of haskell-opencv HEAD where we got the following error:
+    # libgomp: Out of memory allocating 927712937064 bytes
+    (fetchpatch {
+      url = https://github.com/opencv/opencv/commit/e1ac8589f8a19b9bf5598bbae073ae12721c541d.patch;
+      sha256 = "1ap2818lixjhc5jgf779c57kwacafc0ap40lqrx6nqfz31silglj";
+    })
+  ] ++
     # Fixes issue: https://github.com/opencv/opencv_contrib/issues/1923
     # PR: https://github.com/opencv/opencv_contrib/pull/1913
     lib.optional buildContrib (fetchpatch {