summary refs log tree commit diff
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2023-08-13 23:02:49 -0500
committerAustin Seipp <aseipp@pobox.com>2023-08-15 16:04:39 -0500
commit0570c3fdf64849f2bc5d127cb5d3c2f070ff3254 (patch)
tree8187e9c64e1cd82c47929ebd81f680a856621efb
parenta2b5bc0785a893c2845934f2c40e36a16f6bffde (diff)
downloadnixpkgs-0570c3fdf64849f2bc5d127cb5d3c2f070ff3254.tar
nixpkgs-0570c3fdf64849f2bc5d127cb5d3c2f070ff3254.tar.gz
nixpkgs-0570c3fdf64849f2bc5d127cb5d3c2f070ff3254.tar.bz2
nixpkgs-0570c3fdf64849f2bc5d127cb5d3c2f070ff3254.tar.lz
nixpkgs-0570c3fdf64849f2bc5d127cb5d3c2f070ff3254.tar.xz
nixpkgs-0570c3fdf64849f2bc5d127cb5d3c2f070ff3254.tar.zst
nixpkgs-0570c3fdf64849f2bc5d127cb5d3c2f070ff3254.zip
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>
-rw-r--r--pkgs/development/libraries/gdal/default.nix123
-rw-r--r--pkgs/top-level/all-packages.nix4
2 files changed, 69 insertions, 58 deletions
diff --git a/pkgs/development/libraries/gdal/default.nix b/pkgs/development/libraries/gdal/default.nix
index 4b29d8f6183..77763fe6ccd 100644
--- a/pkgs/development/libraries/gdal/default.nix
+++ b/pkgs/development/libraries/gdal/default.nix
@@ -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
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 99c7b699914..b23a980005b 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -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;
   };