diff --git a/flake.nix b/flake.nix index 6394185a..e408029b 100644 --- a/flake.nix +++ b/flake.nix @@ -42,10 +42,32 @@ ### PACKAGES ### # + + + # # default.nix + # let + # python-packages = forAllPythonVersions (python: (lib.makeScope final.newScope (final: { + # inherit python; + # pythonPackages = python.pkgs; + + # fiona = final.callPackage ./fiona {}; + # # ... + # }))); + # in + + # # fiona.nix + # { pythonPackages, geos }: + + # pythonPackages.buildPythonApplication { + + # } + + + packages = let - inherit (nixpkgs.lib) forEach genAttrs mapAttrs'; + inherit (nixpkgs.lib) forEach genAttrs makeScope mapAttrs'; inherit (nixpkgs.lib.attrsets) attrValues filterAttrs mergeAttrsList; pythonVersions = [ @@ -76,198 +98,202 @@ [ "${prefix}-__toString" ]; - geonixcli = pkgs.callPackage ./pkgs/geonixcli { }; - - - # Core libs - gdal = pkgs.callPackage ./pkgs/gdal { - inherit geos libgeotiff libspatialite proj tiledb; - useJava = false; - }; - gdal-minimal = pkgs.callPackage ./pkgs/gdal { - inherit geos libgeotiff libspatialite proj tiledb; - useMinimalFeatures = true; - }; - _gdal = gdal; - - geos = pkgs.callPackage ./pkgs/geos { }; + geopkgs = makeScope pkgs.newScope (final: { + geonixcli = final.callPackage ./pkgs/geonixcli { }; - libgeotiff = pkgs.callPackage ./pkgs/libgeotiff { - inherit proj; - }; - librttopo = pkgs.callPackage ./pkgs/librttopo { - inherit geos; - }; + # Core libs + gdal = final.callPackage ./pkgs/gdal { + # inherit geos libgeotiff libspatialite proj tiledb; + useJava = false; + }; + gdal-minimal = final.callPackage ./pkgs/gdal { + # inherit geos libgeotiff libspatialite proj tiledb; + useMinimalFeatures = true; + }; + _gdal = final.gdal; - libspatialindex = pkgs.callPackage ./pkgs/libspatialindex { }; + geos = final.callPackage ./pkgs/geos { }; - libspatialite = pkgs.callPackage ./pkgs/libspatialite { - inherit geos librttopo proj; - }; + libgeotiff = final.callPackage ./pkgs/libgeotiff { + # inherit proj; + }; - pdal = pkgs.callPackage ./pkgs/pdal { - inherit gdal libgeotiff proj tiledb; - }; + librttopo = final.callPackage ./pkgs/librttopo { + # inherit geos; + }; - proj = pkgs.callPackage ./pkgs/proj { }; + libspatialindex = final.callPackage ./pkgs/libspatialindex { }; + libspatialite = final.callPackage ./pkgs/libspatialite { + # inherit geos librttopo proj; + }; - # Python packages - python-packages = forAllPythonVersions (python: rec { - fiona = pkgs.${python}.pkgs.callPackage ./pkgs/fiona { - inherit gdal; + pdal = final.callPackage ./pkgs/pdal { + # inherit gdal libgeotiff proj tiledb; }; - gdal = pkgs.${python}.pkgs.toPythonModule (_gdal); + proj = final.callPackage ./pkgs/proj { }; - geopandas = pkgs.${python}.pkgs.callPackage ./pkgs/geopandas { - inherit fiona pyproj shapely; - }; - owslib = pkgs.${python}.pkgs.callPackage ./pkgs/owslib { - inherit pyproj; - }; + # Python packages + python-packages = forAllPythonVersions (python: (makeScope pkgs.${python}.pkgs.newScope (pyFinal: { + nonPythonFinal = final; - psycopg = pkgs.${python}.pkgs.psycopg.override { - inherit shapely; - }; + fiona = pyFinal.callPackage ./pkgs/fiona { + # inherit gdal; + }; - pyproj = pkgs.${python}.pkgs.callPackage ./pkgs/pyproj { - inherit proj shapely; - }; + # gdal = pkgs.${python}.pkgs.toPythonModule (final._gdal); - pyqt5 = pkgs.${python}.pkgs.pyqt5.override { - # FIX sip and pyqt5_sip compatibility. See: https://github.com/NixOS/nixpkgs/issues/273561 - # Remove this fix in NixOS 24.05. - pyqt5_sip = pkgs.${python}.pkgs.callPackage ./pkgs/qgis/pyqt5-sip.nix { }; - withLocation = true; - withSerialPort = true; - }; + geopandas = pyFinal.callPackage ./pkgs/geopandas { + # inherit fiona pyproj shapely; + }; - rasterio = pkgs.${python}.pkgs.callPackage ./pkgs/rasterio { - inherit gdal shapely; - }; + owslib = pyFinal.callPackage ./pkgs/owslib { + # inherit pyproj; + }; - shapely = pkgs.${python}.pkgs.callPackage ./pkgs/shapely { - inherit geos; - }; + psycopg = pyFinal.psycopg.override { + # inherit shapely; + }; - # all packages (single Python version) - all-packages = pkgs.symlinkJoin { - name = "all-${python}-packages"; - paths = [ - fiona - gdal - geopandas - owslib - psycopg - pyproj - pyqt5 - rasterio - shapely - ]; - }; + pyproj = pyFinal.callPackage ./pkgs/pyproj { + # inherit proj shapely; + }; - __toString = self: python; - }); + pyqt5 = pyFinal.pyqt5.override { + # FIX sip and pyqt5_sip compatibility. See: https://github.com/NixOS/nixpkgs/issues/273561 + # Remove this fix in NixOS 24.05. + pyqt5_sip = final.callPackage ./pkgs/qgis/pyqt5-sip.nix { }; + withLocation = true; + withSerialPort = true; + }; + rasterio = pyFinal.callPackage ./pkgs/rasterio { + # inherit gdal shapely; + }; - # Postgresql packages - postgresql-packages = forAllPostgresqlVersions (postgresql: rec { + shapely = pyFinal.callPackage ./pkgs/shapely { + # inherit geos; + }; - postgis = pkgs.callPackage ./pkgs/postgis/postgis.nix { - inherit geos proj; + # # all packages (single Python version) + # all-packages = pkgs.symlinkJoin { + # name = "all-${python}-packages"; + # paths = [ + # pyFinal.fiona + # # pyFinal.gdal + # pyFinal.geopandas + # pyFinal.owslib + # pyFinal.psycopg + # pyFinal.pyproj + # pyFinal.pyqt5 + # pyFinal.rasterio + # pyFinal.shapely + # ]; + # }; - gdalMinimal = gdal-minimal; - postgresql = pkgs.${postgresql}; - }; + __toString = self: python; + }))); - # all packages (single Postgresql version) - all-packages = pkgs.symlinkJoin { - name = "all-${postgresql}-packages"; - paths = [ - postgis - ]; - }; - __toString = self: postgresql; - }); + # Postgresql packages + postgresql-packages = forAllPostgresqlVersions (postgresql: rec { + postgis = final.callPackage ./pkgs/postgis/postgis.nix { + # inherit geos proj; - # PG_Featureserv - pg_featureserv = pkgs.callPackage ./pkgs/pg_featureserv { }; + gdalMinimal = final.gdal-minimal; + postgresql = pkgs.${postgresql}; + }; - # PG_Tileserv - pg_tileserv = pkgs.callPackage ./pkgs/pg_tileserv { }; + # # all packages (single Postgresql version) + # all-packages = pkgs.symlinkJoin { + # name = "all-${postgresql}-packages"; + # paths = [ + # postgis + # ]; + # }; - # TileDB - tiledb = pkgs.callPackage ./pkgs/tiledb { }; + __toString = self: postgresql; + }); - # GRASS - grass = pkgs.callPackage ./pkgs/grass { - inherit gdal geos pdal proj; - }; + # PG_Featureserv + pg_featureserv = final.callPackage ./pkgs/pg_featureserv { }; + # PG_Tileserv + pg_tileserv = final.callPackage ./pkgs/pg_tileserv { }; - # QGIS - qgis-unwrapped = - let - qgis-python = - let - packageOverrides = final: prev: { - pyqt5 = python-packages.python3.pyqt5; - owslib = python-packages.python3.owslib; - gdal = python-packages.python3.gdal; - }; - in - pkgs.python3.override { inherit packageOverrides; self = qgis-python; }; - in - pkgs.libsForQt5.callPackage ./pkgs/qgis/unwrapped.nix { - inherit geos gdal libspatialindex libspatialite pdal proj; - - python3 = qgis-python; - withGrass = false; - }; + # TileDB + tiledb = final.callPackage ./pkgs/tiledb { }; - qgis = pkgs.callPackage ./pkgs/qgis { qgis-unwrapped = qgis-unwrapped; }; - - # QGIS-LTR - qgis-ltr-unwrapped = - let - qgis-python = - let - packageOverrides = final: prev: { - pyqt5 = python-packages.python3.pyqt5; - owslib = python-packages.python3.owslib; - gdal = python-packages.python3.gdal; - }; - in - pkgs.python3.override { inherit packageOverrides; self = qgis-python; }; - in - pkgs.libsForQt5.callPackage ./pkgs/qgis/unwrapped-ltr.nix { - inherit geos gdal libspatialindex libspatialite pdal proj; - - python3 = qgis-python; - withGrass = false; - }; - qgis-ltr = pkgs.callPackage ./pkgs/qgis/ltr.nix { qgis-ltr-unwrapped = qgis-ltr-unwrapped; }; + # GRASS + grass = final.callPackage ./pkgs/grass { + # inherit gdal geos pdal proj; + }; - # nixGL - nixGL = nixgl.packages.${system}.nixGLIntel; - # all-packages (meta package containing all packages) - all-packages = pkgs.symlinkJoin { - name = "all-packages"; - paths = attrValues (filterAttrs (n: v: n != "all-packages") self.packages.${system}); - }; + # QGIS + qgis-unwrapped = + let + qgis-python = + let + packageOverrides = final: prev: { + # pyqt5 = final.python-packages.python3.pyqt5; + # owslib = final.python-packages.python3.owslib; + # gdal = final.python-packages.python3.gdal; + }; + in + pkgs.python3.override { inherit packageOverrides; self = qgis-python; }; + in + pkgs.libsForQt5.callPackage ./pkgs/qgis/unwrapped.nix { + # inherit geos gdal libspatialindex libspatialite pdal proj; + + python3 = qgis-python; + withGrass = false; + }; + + qgis = final.callPackage ./pkgs/qgis { qgis-unwrapped = final.qgis-unwrapped; }; + + # QGIS-LTR + qgis-ltr-unwrapped = + let + qgis-python = + let + packageOverrides = localFinal: prev: { + pyqt5 = final.python-packages.python3.pyqt5; + owslib = final.python-packages.python3.owslib; + gdal = final.python-packages.python3.gdal; + }; + in + pkgs.python3.override { inherit packageOverrides; self = qgis-python; }; + in + pkgs.libsForQt5.callPackage ./pkgs/qgis/unwrapped-ltr.nix { + # inherit geos gdal libspatialindex libspatialite pdal proj; + + python3 = qgis-python; + withGrass = false; + }; + + qgis-ltr = final.callPackage ./pkgs/qgis/ltr.nix { qgis-ltr-unwrapped = final.qgis-ltr-unwrapped; }; + + # nixGL + nixGL = nixgl.packages.${system}.nixGLIntel; + + # all-packages (meta package containing all packages) + # all-packages = pkgs.symlinkJoin { + # name = "all-packages"; + # paths = attrValues (filterAttrs (n: v: n != "all-packages") self.packages.${system}); + # }; + }); in flake-utils.lib.filterPackages system { - inherit + inherit (geopkgs) # Core libs gdal @@ -293,17 +319,17 @@ qgis-ltr-unwrapped # Meta packages - all-packages + # all-packages # nixGL nixGL; } # Add Python packages in all versions - // mergeAttrsList (forEach (builtins.attrValues python-packages) (p: prefixPackages p "${p}")) + // mergeAttrsList (forEach (builtins.attrValues geopkgs.python-packages) (p: prefixPackages p "${p}")) # Add Postgresql packages in all versions - // mergeAttrsList (forEach (builtins.attrValues postgresql-packages) (p: prefixPackages p "${p}")); + // mergeAttrsList (forEach (builtins.attrValues geopkgs.postgresql-packages) (p: prefixPackages p "${p}")); #