gdal: introduce 'useMinimalFeatures' flag to reduce closure size

Summary: GDAL has an atrociously large closure weighing in at over
1.3GiB. This makes many things such as packaging PostGIS/PostgreSQL
inside Docker images, or even copying closures, perform pretty poorly.

More importantly, adding unlimited surface area to GDAL is effectively
a support and maintenance burden. This is one of the major motivators
of this patch: to make it possible to reduce the number of supported
raster formats and thus scope support and maintence to specific subsets
of functionality.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2023-08-13 23:02:49 -05:00
parent a2b5bc0785
commit 0570c3fdf6
2 changed files with 69 additions and 58 deletions

View File

@ -3,6 +3,9 @@
, callPackage
, fetchFromGitHub
, useMinimalFeatures ? false
, useTiledb ? (!useMinimalFeatures) && !(stdenv.isDarwin && stdenv.isx86_64)
, bison
, cmake
, gtest
@ -55,7 +58,6 @@
, libspatialite
, sqlite
, libtiff
, useTiledb ? !(stdenv.isDarwin && stdenv.isx86_64)
, tiledb
, libwebp
, xercesc
@ -101,63 +103,68 @@ stdenv.mkDerivation (finalAttrs: {
"-DGDAL_USE_TILEDB=OFF"
];
buildInputs = [
armadillo
c-blosc
brunsli
cfitsio
crunch
curl
cryptopp
libdeflate
expat
libgeotiff
geos
giflib
libheif
dav1d # required by libheif
libaom # required by libheif
libde265 # required by libheif
rav1e # required by libheif
x265 # required by libheif
hdf4
hdf5-cpp
libjpeg
json_c
libjxl
libhwy # required by libjxl
lerc
xz
libxml2
lz4
libmysqlclient
netcdf
openjpeg
openssl
pcre2
libpng
poppler
postgresql
proj
qhull
libspatialite
sqlite
libtiff
gtest
] ++ lib.optionals useTiledb [
tiledb
] ++ [
libwebp
zlib
zstd
python3
python3.pkgs.numpy
] ++ lib.optionals (!stdenv.isDarwin) [
# tests for formats enabled by these packages fail on macos
arrow-cpp
openexr
xercesc
] ++ lib.optional stdenv.isDarwin libiconv;
buildInputs =
let
tileDbDeps = lib.optionals useTiledb [ tiledb ];
darwinDeps = lib.optionals stdenv.isDarwin [ libiconv ];
nonDarwinDeps = lib.optionals (!stdenv.isDarwin) [
# tests for formats enabled by these packages fail on macos
arrow-cpp
openexr
xercesc
];
in [
armadillo
c-blosc
brunsli
cfitsio
crunch
curl
cryptopp
libdeflate
expat
libgeotiff
geos
giflib
libheif
dav1d # required by libheif
libaom # required by libheif
libde265 # required by libheif
rav1e # required by libheif
x265 # required by libheif
hdf4
hdf5-cpp
libjpeg
json_c
libjxl
libhwy # required by libjxl
lerc
xz
libxml2
lz4
libmysqlclient
netcdf
openjpeg
openssl
pcre2
libpng
poppler
postgresql
proj
qhull
libspatialite
sqlite
libtiff
gtest
libwebp
zlib
zstd
python3
python3.pkgs.numpy
] ++ tileDbDeps
++ darwinDeps
++ nonDarwinDeps;
postInstall = ''
wrapPythonPrograms

View File

@ -21330,6 +21330,10 @@ with pkgs;
gdal = callPackage ../development/libraries/gdal { };
gdalMinimal = callPackage ../development/libraries/gdal {
useMinimalFeatures = true;
};
gdcm = callPackage ../development/libraries/gdcm {
inherit (darwin.apple_sdk.frameworks) ApplicationServices Cocoa;
};