1 { lib, stdenv, fetchFromGitHub, fetchpatch, unzip, libjpeg, libtiff, zlib, postgresql
2 , libmysqlclient, libgeotiff, pythonPackages, proj, geos, openssl, libpng
3 , sqlite, libspatialite, poppler, hdf4, qhull, giflib, expat, libiconv, libxml2
4 , autoreconfHook, netcdfSupport ? true, netcdf, hdf5, curl, pkg-config }:
8 stdenv.mkDerivation rec {
12 src = fetchFromGitHub {
16 sha256 = "sha256-bE55VV0SrG8nxCLdpODRalnuAkn+olRdMLUjduavj6M=";
19 sourceRoot = "source/gdal";
21 nativeBuildInputs = [ autoreconfHook pkg-config unzip ];
39 ] ++ (with pythonPackages; [ python setuptools numpy wrapPython ])
40 ++ lib.optional stdenv.isDarwin libiconv
41 ++ lib.optionals netcdfSupport [ netcdf hdf5 curl ];
44 "--with-expat=${expat.dev}"
45 "--with-jpeg=${libjpeg.dev}"
46 "--with-libtiff=${libtiff.dev}" # optional (without largetiff support)
47 "--with-png=${libpng.dev}" # optional
48 "--with-poppler=${poppler.dev}" # optional
49 "--with-libz=${zlib.dev}" # optional
50 "--with-pg=yes" # since gdal 3.0 doesn't use ${postgresql}/bin/pg_config
51 "--with-mysql=${getDev libmysqlclient}/bin/mysql_config"
52 "--with-geotiff=${libgeotiff}"
53 "--with-sqlite3=${sqlite.dev}"
54 "--with-spatialite=${libspatialite.dev}"
55 "--with-python" # optional
56 "--with-proj=${proj.dev}" # optional
57 "--with-geos=${geos}/bin/geos-config" # optional
58 "--with-hdf4=${hdf4.dev}" # optional
59 "--with-xml2=yes" # optional
60 (if netcdfSupport then "--with-netcdf=${netcdf}" else "")
63 hardeningDisable = [ "format" ];
65 CXXFLAGS = lib.concatStringsSep " " [
67 # poppler uses std::optional
71 # - Unset CC and CXX as they confuse libtool.
72 # - teach gdal that libdf is the legacy name for libhdf
74 substituteInPlace configure \
75 --replace "-lmfhdf -ldf" "-lmfhdf -lhdf"
79 substituteInPlace swig/python/GNUmakefile \
80 --replace "ifeq (\$(STD_UNIX_LAYOUT),\"TRUE\")" "ifeq (1,1)"
87 enableParallelBuilding = true;
89 doInstallCheck = true;
90 # preCheck rather than preInstallCheck because this is what pytestCheckHook
91 # calls (coming from the python world)
94 # something has made files here read-only by this point
97 export HOME=$(mktemp -d)
98 export PYTHONPATH="$out/${pythonPackages.python.sitePackages}:$PYTHONPATH"
100 installCheckInputs = with pythonPackages; [
105 disabledTestPaths = [
106 # tests that attempt to make network requests
108 "gdrivers/gdalhttp.py"
112 # tests that attempt to make network requests
113 "test_jp2openjpeg_45"
114 # tests that require the full proj dataset which we don't package yet
115 # https://github.com/OSGeo/gdal/issues/5523
116 "test_transformer_dem_overrride_srs"
117 "test_osr_ct_options_area_of_interest"
118 ] ++ lib.optionals (!stdenv.isx86_64) [
119 # likely precision-related expecting x87 behaviour
120 "test_jp2openjpeg_22"
121 ] ++ lib.optionals stdenv.isDarwin [
123 "test_rda_download_queue"
130 description = "Translator library for raster geospatial data formats";
131 homepage = "https://www.gdal.org/";
132 license = lib.licenses.mit;
133 maintainers = [ lib.maintainers.marcweber ];
134 platforms = with lib.platforms; linux ++ darwin;