Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
flake: build geopkgs in scope
Browse files Browse the repository at this point in the history
  • Loading branch information
imincik committed May 26, 2024
1 parent 91cfd88 commit f0842fa
Showing 1 changed file with 178 additions and 154 deletions.
332 changes: 178 additions & 154 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -76,198 +98,200 @@
[ "${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;
geopkgs = makeScope pkgs.newScope (final: {
geonixcli = final.callPackage ./pkgs/geonixcli { };

geos = pkgs.callPackage ./pkgs/geos { };

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: rec {
fiona = pkgs.${python}.pkgs.callPackage ./pkgs/fiona {
# inherit gdal;
};

psycopg = pkgs.${python}.pkgs.psycopg.override {
inherit shapely;
};
gdal = pkgs.${python}.pkgs.toPythonModule (final._gdal);

pyproj = pkgs.${python}.pkgs.callPackage ./pkgs/pyproj {
inherit proj shapely;
};
geopandas = pkgs.${python}.pkgs.callPackage ./pkgs/geopandas {
# inherit fiona pyproj shapely;
};

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;
};
owslib = pkgs.${python}.pkgs.callPackage ./pkgs/owslib {
# inherit pyproj;
};

rasterio = pkgs.${python}.pkgs.callPackage ./pkgs/rasterio {
inherit gdal shapely;
};
psycopg = pkgs.${python}.pkgs.psycopg.override {
# inherit shapely;
};

shapely = pkgs.${python}.pkgs.callPackage ./pkgs/shapely {
inherit geos;
};
pyproj = pkgs.${python}.pkgs.callPackage ./pkgs/pyproj {
# inherit proj shapely;
};

# all packages (single Python version)
all-packages = pkgs.symlinkJoin {
name = "all-${python}-packages";
paths = [
fiona
gdal
geopandas
owslib
psycopg
pyproj
pyqt5
rasterio
shapely
];
};
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;
};

__toString = self: python;
});
rasterio = pkgs.${python}.pkgs.callPackage ./pkgs/rasterio {
# inherit gdal shapely;
};

shapely = pkgs.${python}.pkgs.callPackage ./pkgs/shapely {
# inherit geos;
};

# Postgresql packages
postgresql-packages = forAllPostgresqlVersions (postgresql: rec {
# all packages (single Python version)
all-packages = pkgs.symlinkJoin {
name = "all-${python}-packages";
paths = [
fiona
gdal
geopandas
owslib
psycopg
pyproj
pyqt5
rasterio
shapely
];
};

postgis = pkgs.callPackage ./pkgs/postgis/postgis.nix {
inherit geos proj;
__toString = self: python;
});

gdalMinimal = gdal-minimal;
postgresql = pkgs.${postgresql};
};

# all packages (single Postgresql version)
all-packages = pkgs.symlinkJoin {
name = "all-${postgresql}-packages";
paths = [
postgis
];
};
# Postgresql packages
postgresql-packages = forAllPostgresqlVersions (postgresql: rec {

__toString = self: postgresql;
});
postgis = final.callPackage ./pkgs/postgis/postgis.nix {
# inherit geos proj;

gdalMinimal = final.gdal-minimal;
postgresql = pkgs.${postgresql};
};

# PG_Featureserv
pg_featureserv = pkgs.callPackage ./pkgs/pg_featureserv { };
# all packages (single Postgresql version)
all-packages = pkgs.symlinkJoin {
name = "all-${postgresql}-packages";
paths = [
postgis
];
};

# PG_Tileserv
pg_tileserv = pkgs.callPackage ./pkgs/pg_tileserv { };
__toString = self: postgresql;
});

# TileDB
tiledb = pkgs.callPackage ./pkgs/tiledb { };

# PG_Featureserv
pg_featureserv = final.callPackage ./pkgs/pg_featureserv { };

# GRASS
grass = pkgs.callPackage ./pkgs/grass {
inherit gdal geos pdal proj;
};
# PG_Tileserv
pg_tileserv = final.callPackage ./pkgs/pg_tileserv { };

# TileDB
tiledb = final.callPackage ./pkgs/tiledb { };

# 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;
};

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;
# GRASS
grass = final.callPackage ./pkgs/grass {
# inherit gdal geos pdal proj;
};

qgis-ltr = pkgs.callPackage ./pkgs/qgis/ltr.nix { qgis-ltr-unwrapped = 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});
};
# 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 = 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-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
Expand Down Expand Up @@ -300,10 +324,10 @@
}

# 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}"));


#
Expand Down

0 comments on commit f0842fa

Please sign in to comment.