nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenv
3, fetchFromGitHub
4, bison
5, cmake
6, doxygen
7, graphviz
8, pkg-config
9, python3
10, swig
11, armadillo
12, arrow-cpp
13, c-blosc
14, brunsli
15, cfitsio
16, crunch
17, curl
18, cryptopp
19, libdeflate
20, expat
21, libgeotiff
22, geos
23, giflib
24, libheif
25, dav1d
26, libaom
27, libde265
28, rav1e
29, x265
30, hdf4
31, hdf5-cpp
32, libiconv
33, libjpeg
34, json_c
35, libjxl
36, libhwy
37, lerc
38, xz
39, libxml2
40, lz4
41, libmysqlclient
42, netcdf
43, openexr
44, openjpeg
45, openssl
46, pcre2
47, libpng
48, poppler
49, postgresql
50, proj
51, qhull
52, libspatialite
53, sqlite
54, libtiff
55, useTiledb ? !(stdenv.isDarwin && stdenv.isx86_64)
56, tiledb
57, libwebp
58, xercesc
59, zlib
60, zstd
61}:
62
63stdenv.mkDerivation rec {
64 pname = "gdal";
65 version = "3.6.4";
66
67 src = fetchFromGitHub {
68 owner = "OSGeo";
69 repo = "gdal";
70 rev = "v${version}";
71 hash = "sha256-pGdZmQBUuNCk9/scUvq4vduINu5gqtCRLaz7QE2e6WU=";
72 };
73
74 nativeBuildInputs = [
75 bison
76 cmake
77 doxygen
78 graphviz
79 pkg-config
80 python3.pkgs.setuptools
81 python3.pkgs.wrapPython
82 swig
83 ];
84
85 cmakeFlags = [
86 "-DGDAL_USE_INTERNAL_LIBS=OFF"
87 "-DGEOTIFF_INCLUDE_DIR=${lib.getDev libgeotiff}/include"
88 "-DGEOTIFF_LIBRARY_RELEASE=${lib.getLib libgeotiff}/lib/libgeotiff${stdenv.hostPlatform.extensions.sharedLibrary}"
89 "-DMYSQL_INCLUDE_DIR=${lib.getDev libmysqlclient}/include/mysql"
90 "-DMYSQL_LIBRARY=${lib.getLib libmysqlclient}/lib/${lib.optionalString (libmysqlclient.pname != "mysql") "mysql/"}libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary}"
91 ] ++ lib.optionals (!stdenv.isDarwin) [
92 "-DCMAKE_SKIP_BUILD_RPATH=ON" # without, libgdal.so can't find libmariadb.so
93 ] ++ lib.optionals stdenv.isDarwin [
94 "-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON"
95 ] ++ lib.optionals (!useTiledb) [
96 "-DGDAL_USE_TILEDB=OFF"
97 ];
98
99 buildInputs = [
100 armadillo
101 c-blosc
102 brunsli
103 cfitsio
104 crunch
105 curl
106 cryptopp
107 libdeflate
108 expat
109 libgeotiff
110 geos
111 giflib
112 libheif
113 dav1d # required by libheif
114 libaom # required by libheif
115 libde265 # required by libheif
116 rav1e # required by libheif
117 x265 # required by libheif
118 hdf4
119 hdf5-cpp
120 libjpeg
121 json_c
122 libjxl
123 libhwy # required by libjxl
124 lerc
125 xz
126 libxml2
127 lz4
128 libmysqlclient
129 netcdf
130 openjpeg
131 openssl
132 pcre2
133 libpng
134 poppler
135 postgresql
136 proj
137 qhull
138 libspatialite
139 sqlite
140 libtiff
141 ] ++ lib.optionals useTiledb [
142 tiledb
143 ] ++ [
144 libwebp
145 zlib
146 zstd
147 python3
148 python3.pkgs.numpy
149 ] ++ lib.optionals (!stdenv.isDarwin) [
150 # tests for formats enabled by these packages fail on macos
151 arrow-cpp
152 openexr
153 xercesc
154 ] ++ lib.optional stdenv.isDarwin libiconv;
155
156 postInstall = ''
157 wrapPythonPrograms
158 '';
159
160 enableParallelBuilding = true;
161
162 doInstallCheck = true;
163 # preCheck rather than preInstallCheck because this is what pytestCheckHook
164 # calls (coming from the python world)
165 preCheck = ''
166 pushd ../autotest
167
168 export HOME=$(mktemp -d)
169 export PYTHONPATH="$out/${python3.sitePackages}:$PYTHONPATH"
170 '';
171 nativeInstallCheckInputs = with python3.pkgs; [
172 pytestCheckHook
173 pytest-env
174 lxml
175 ];
176 disabledTestPaths = [
177 # tests that attempt to make network requests
178 "gcore/vsis3.py"
179 "gdrivers/gdalhttp.py"
180 "gdrivers/wms.py"
181 ];
182 disabledTests = [
183 # tests that attempt to make network requests
184 "test_jp2openjpeg_45"
185 # tests that require the full proj dataset which we don't package yet
186 # https://github.com/OSGeo/gdal/issues/5523
187 "test_transformer_dem_overrride_srs"
188 "test_osr_ct_options_area_of_interest"
189 # ZIP does not support timestamps before 1980
190 " test_sentinel2_zipped"
191 # tries to call unwrapped executable
192 "test_SetPROJAuxDbPaths"
193 ] ++ lib.optionals (!stdenv.isx86_64) [
194 # likely precision-related expecting x87 behaviour
195 "test_jp2openjpeg_22"
196 ] ++ lib.optionals stdenv.isDarwin [
197 # flaky on macos
198 "test_rda_download_queue"
199 ] ++ lib.optionals (lib.versionOlder proj.version "8") [
200 "test_ogr_parquet_write_crs_without_id_in_datum_ensemble_members"
201 ];
202 postCheck = ''
203 popd # ../autotest
204 '';
205
206 __darwinAllowLocalNetworking = true;
207
208 meta = {
209 description = "Translator library for raster geospatial data formats";
210 homepage = "https://www.gdal.org/";
211 changelog = "https://github.com/OSGeo/gdal/blob/${src.rev}/NEWS.md";
212 license = lib.licenses.mit;
213 maintainers = with lib.maintainers; [ marcweber dotlambda ];
214 platforms = lib.platforms.unix;
215 };
216}