From b57af2d024b13784dad35aac282533fc09797b58 Mon Sep 17 00:00:00 2001
From: brano543 <brano.masar@gmail.com>
Date: Sat, 15 Feb 2020 13:09:14 +0100
Subject: [PATCH] gdal: Fix finding postgresql after 3.0 update

---
 pkgs/development/libraries/gdal/default.nix | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/pkgs/development/libraries/gdal/default.nix b/pkgs/development/libraries/gdal/default.nix
index ed31d34f65e4..085c23c49cf4 100644
--- a/pkgs/development/libraries/gdal/default.nix
+++ b/pkgs/development/libraries/gdal/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, fetchpatch, unzip, libjpeg, libtiff, zlib, postgresql
 , libmysqlclient, libgeotiff, pythonPackages, proj, geos, openssl, libpng
 , sqlite, libspatialite, poppler, hdf4, qhull, giflib, expat, libiconv, libxml2
-, autoreconfHook, netcdfSupport ? true, netcdf, hdf5, curl }:
+, autoreconfHook, netcdfSupport ? true, netcdf, hdf5, curl, pkg-config }:
 
 with stdenv.lib;
 
@@ -18,7 +18,7 @@ stdenv.mkDerivation rec {
 
   sourceRoot = "source/gdal";
 
-  nativeBuildInputs = [ autoreconfHook ];
+  nativeBuildInputs = [ autoreconfHook pkg-config ];
 
   buildInputs = [
     unzip
@@ -36,6 +36,7 @@ stdenv.mkDerivation rec {
     giflib
     expat
     libxml2
+    postgresql
   ] ++ (with pythonPackages; [ python numpy wrapPython ])
     ++ stdenv.lib.optional stdenv.isDarwin libiconv
     ++ stdenv.lib.optionals netcdfSupport [ netcdf hdf5 curl ];
@@ -47,7 +48,7 @@ stdenv.mkDerivation rec {
     "--with-png=${libpng.dev}" # optional
     "--with-poppler=${poppler.dev}" # optional
     "--with-libz=${zlib.dev}" # optional
-    "--with-pg=${postgresql}/bin/pg_config"
+    "--with-pg=yes" # since gdal 3.0 doesn't use ${postgresql}/bin/pg_config
     "--with-mysql=${libmysqlclient}/bin/mysql_config"
     "--with-geotiff=${libgeotiff}"
     "--with-sqlite3=${sqlite.dev}"