7 useMinimalFeatures ? false,
8 useArmadillo ? (!useMinimalFeatures),
9 useArrow ? (!useMinimalFeatures),
10 useHDF ? (!useMinimalFeatures),
11 useJava ? (!useMinimalFeatures),
12 useLibAvif ? (!useMinimalFeatures),
13 useLibHEIF ? (!useMinimalFeatures),
14 useLibJXL ? (!useMinimalFeatures),
15 useMysql ? (!useMinimalFeatures),
16 useNetCDF ? (!useMinimalFeatures),
17 usePoppler ? (!useMinimalFeatures),
18 usePostgres ? (!useMinimalFeatures),
20 (!useMinimalFeatures) && !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64),
84 stdenv.mkDerivation (finalAttrs: {
85 pname = "gdal" + lib.optionalString useMinimalFeatures "-minimal";
88 src = fetchFromGitHub {
91 rev = "v${finalAttrs.version}";
92 hash = "sha256-pb2xKTmJB7U1jIG80ENmZrR7vFw6YDoees43u/JhU3Y=";
102 python3.pkgs.setuptools
103 python3.pkgs.wrapPython
106 ++ lib.optionals useJava [
113 "-DGDAL_USE_INTERNAL_LIBS=OFF"
114 "-DGEOTIFF_INCLUDE_DIR=${lib.getDev libgeotiff}/include"
115 "-DGEOTIFF_LIBRARY_RELEASE=${lib.getLib libgeotiff}/lib/libgeotiff${stdenv.hostPlatform.extensions.sharedLibrary}"
116 "-DMYSQL_INCLUDE_DIR=${lib.getDev libmysqlclient}/include/mysql"
117 "-DMYSQL_LIBRARY=${lib.getLib libmysqlclient}/lib/${
118 lib.optionalString (libmysqlclient.pname != "mysql") "mysql/"
119 }libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary}"
121 ++ lib.optionals finalAttrs.doInstallCheck [
124 ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
125 "-DCMAKE_SKIP_BUILD_RPATH=ON" # without, libgdal.so can't find libmariadb.so
127 ++ lib.optionals stdenv.hostPlatform.isDarwin [
128 "-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON"
130 ++ lib.optionals (!useTiledb) [
131 "-DGDAL_USE_TILEDB=OFF"
133 ++ lib.optionals (!useJava) [
134 # This is not strictly needed as the Java bindings wouldn't build anyway if
135 # ant/jdk were not available.
136 "-DBUILD_JAVA_BINDINGS=OFF"
141 tileDbDeps = lib.optionals useTiledb [ tiledb ];
142 libAvifDeps = lib.optionals useLibAvif [ libavif ];
143 libHeifDeps = lib.optionals useLibHEIF [
151 libJxlDeps = lib.optionals useLibJXL [
155 mysqlDeps = lib.optionals useMysql [ libmysqlclient ];
156 postgresDeps = lib.optionals usePostgres [ postgresql ];
157 popplerDeps = lib.optionals usePoppler [ poppler ];
158 arrowDeps = lib.optionals useArrow [ arrow-cpp ];
159 hdfDeps = lib.optionals useHDF [
163 netCdfDeps = lib.optionals useNetCDF [ netcdf ];
164 armadilloDeps = lib.optionals useArmadillo [ armadillo ];
166 darwinDeps = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
167 nonDarwinDeps = lib.optionals (!stdenv.hostPlatform.isDarwin) (
169 # tests for formats enabled by these packages fail on macos
192 (libxml2.override { enableHttp = true; })
224 pythonPath = [ python3.pkgs.numpy ];
227 wrapPythonProgramsIn "$out/bin" "$out $pythonPath"
229 + lib.optionalString useJava ''
231 ln -s ./jni/libgdalalljni${stdenv.hostPlatform.extensions.sharedLibrary}
235 enableParallelBuilding = true;
237 doInstallCheck = true;
238 # preCheck rather than preInstallCheck because this is what pytestCheckHook
239 # calls (coming from the python world)
243 export HOME=$(mktemp -d)
244 export PYTHONPATH="$out/${python3.sitePackages}:$PYTHONPATH"
245 export GDAL_DOWNLOAD_TEST_DATA=OFF
246 # allows to skip tests that fail because of file handle leak
247 # the issue was not investigated
248 # https://github.com/OSGeo/gdal/blob/v3.9.0/autotest/gdrivers/bag.py#L54
251 nativeInstallCheckInputs = with python3.pkgs; [
259 "--benchmark-disable"
261 disabledTestPaths = [
262 # tests that attempt to make network requests
264 "gdrivers/gdalhttp.py"
269 # tests that attempt to make network requests
270 "test_jp2openjpeg_45"
271 # tests that require the full proj dataset which we don't package yet
272 # https://github.com/OSGeo/gdal/issues/5523
273 "test_transformer_dem_overrride_srs"
274 "test_osr_ct_options_area_of_interest"
275 # ZIP does not support timestamps before 1980
276 "test_sentinel2_zipped"
277 # tries to call unwrapped executable
278 "test_SetPROJAuxDbPaths"
279 # failing for unknown reason
280 # https://github.com/OSGeo/gdal/pull/10806#issuecomment-2362054085
281 "test_ogr_gmlas_billion_laugh"
282 # Flaky on hydra, collected in https://github.com/NixOS/nixpkgs/pull/327323.
283 "test_ogr_gmlas_huge_processing_time"
284 "test_ogr_gpkg_background_rtree_build"
285 "test_vsiaz_fake_write"
288 ++ lib.optionals (!stdenv.hostPlatform.isx86_64) [
289 # likely precision-related expecting x87 behaviour
290 "test_jp2openjpeg_22"
292 ++ lib.optionals stdenv.hostPlatform.isDarwin [
294 "test_rda_download_queue"
296 ++ lib.optionals (lib.versionOlder proj.version "8") [
297 "test_ogr_parquet_write_crs_without_id_in_datum_ensemble_members"
299 ++ lib.optionals (!usePoppler) [
300 "test_pdf_jpx_compression"
306 passthru.tests = callPackage ./tests.nix { gdal = finalAttrs.finalPackage; };
308 __darwinAllowLocalNetworking = true;
311 changelog = "https://github.com/OSGeo/gdal/blob/v${finalAttrs.version}/NEWS.md";
312 description = "Translator library for raster geospatial data formats";
313 homepage = "https://www.gdal.org/";
314 license = licenses.mit;
317 teams.geospatial.members
322 platforms = platforms.unix;