From d9113fc57eec6ad5d74cdd0c095c214fbfe3c416 Mon Sep 17 00:00:00 2001 From: Ivan Mincik Date: Tue, 17 Jun 2025 16:36:23 +0200 Subject: [PATCH] nominatim: 4.4.0 -> 5.1.0 This is a major update. Nominatim is split in to two packages: * python3Packages.nominatim-api * nominatim - contains nominatim-db and nominatim CLI Geospatial team is added as a co-maintainer. --- pkgs/by-name/no/nominatim/nominatim-api.nix | 62 ++++++++++ pkgs/by-name/no/nominatim/package.nix | 122 ++++++++++---------- pkgs/top-level/python-packages.nix | 2 + 3 files changed, 122 insertions(+), 64 deletions(-) create mode 100644 pkgs/by-name/no/nominatim/nominatim-api.nix diff --git a/pkgs/by-name/no/nominatim/nominatim-api.nix b/pkgs/by-name/no/nominatim/nominatim-api.nix new file mode 100644 index 000000000000..6cda6ae63662 --- /dev/null +++ b/pkgs/by-name/no/nominatim/nominatim-api.nix @@ -0,0 +1,62 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + + hatchling, + psycopg, + pyicu, + python-dotenv, + pyyaml, + sqlalchemy, +}: + +buildPythonPackage rec { + pname = "nominatim"; + version = "5.1.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "osm-search"; + repo = "Nominatim"; + tag = "v${version}"; + hash = "sha256-eMCXXPrUZvM4ju0mi1+f+LXhThCCCEH+HDz6lurw+Jo="; + }; + + postPatch = '' + # pyproject.toml tool.hatch.build.targets.sdist.exclude is not properly + # excluding config.py file. + # Fix FileExistsError: File already exists: ... nominatim_api/config.py + rm src/nominatim_api/config.py + + # Change to package directory + cd packaging/nominatim-api + ''; + + build-system = [ + hatchling + ]; + + dependencies = [ + psycopg + pyicu + python-dotenv + pyyaml + sqlalchemy + ]; + + # Fails on: ModuleNotFoundError: No module named 'nominatim_db' + # pythonImportsCheck = [ "nominatim_api" ]; + + meta = { + description = "Search engine for OpenStreetMap data (API module)"; + homepage = "https://nominatim.org/"; + license = lib.licenses.gpl2Plus; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ mausch ]; + teams = with lib.teams; [ + geospatial + ngi + ]; + }; +} diff --git a/pkgs/by-name/no/nominatim/package.nix b/pkgs/by-name/no/nominatim/package.nix index afaf7d93b08e..add1001d86ef 100644 --- a/pkgs/by-name/no/nominatim/package.nix +++ b/pkgs/by-name/no/nominatim/package.nix @@ -1,89 +1,83 @@ { - stdenv, lib, fetchFromGitHub, fetchurl, - clang-tools, - cmake, - bzip2, - zlib, - expat, - boost, - git, - pandoc, - nlohmann_json, - # Nominatim needs to be built with the same postgres version it will target - libpq, - python3, - php, - lua, + + osm2pgsql, + python3Packages, + + nominatim, # required for testVersion + testers, }: let countryGrid = fetchurl { - # Nominatim docs mention https://www.nominatim.org/data/country_grid.sql.gz but it's not a very good URL for pinning + # Nominatim-db needs https://www.nominatim.org/data/country_grid.sql.gz + # but it's not a very good URL for pinning url = "https://web.archive.org/web/20220323041006/https://nominatim.org/data/country_grid.sql.gz"; - sha256 = "sha256-/mY5Oq9WF0klXOv0xh0TqEJeMmuM5QQJ2IxANRZd4Ek="; + hash = "sha256-/mY5Oq9WF0klXOv0xh0TqEJeMmuM5QQJ2IxANRZd4Ek="; }; in -stdenv.mkDerivation rec { +python3Packages.buildPythonApplication rec { pname = "nominatim"; - version = "4.4.0"; + version = "5.1.0"; + pyproject = true; src = fetchFromGitHub { owner = "osm-search"; repo = "Nominatim"; - rev = "v${version}"; - fetchSubmodules = true; - hash = "sha256-GPMDbvTPl9SLpZi5gyRAPQ84NSTIRoSfGJeqWs1e9Oo="; + tag = "v${version}"; + hash = "sha256-eMCXXPrUZvM4ju0mi1+f+LXhThCCCEH+HDz6lurw+Jo="; }; - nativeBuildInputs = [ - cmake - clang-tools - git - pandoc - php - lua - ]; - - buildInputs = [ - bzip2 - zlib - expat - boost - nlohmann_json - (python3.withPackages ( - ps: with ps; [ - pyyaml - python-dotenv - psycopg2 - sqlalchemy - asyncpg - psutil - jinja2 - pyicu - datrie - pyosmium - ] - )) - # python3Packages.pylint # We don't want to run pylint because the package could break on pylint bumps which is really annoying. - # python3Packages.pytest # disabled since I can't get it to run tests anyway - # python3Packages.behave # disabled since I can't get it to run tests anyway - libpq - ]; - postPatch = '' - mkdir -p ./data - ln -s ${countryGrid} ./data/country_osm_grid.sql.gz + # Fix: FileExistsError: File already exists: ... nominatim_db/paths.py + # pyproject.toml tool.hatch.build.targets.sdist.exclude is not properly + # excluding paths.py file. + rm src/nominatim_db/paths.py + + # Install country_osm_grid.sql.gz required for data import + cp ${countryGrid} ./data/country_osm_grid.sql.gz + + # Change to package directory + cd packaging/nominatim-db ''; - meta = with lib; { - description = "Search engine for OpenStreetMap data"; + build-system = with python3Packages; [ + hatchling + ]; + + dependencies = with python3Packages; [ + nominatim-api + + jinja2 + psutil + psycopg + pyicu + python-dotenv + pyyaml + ]; + + propagatedBuildInputs = [ + osm2pgsql + ]; + + pythonImportsCheck = [ "nominatim_db" ]; + + passthru = { + tests.version = testers.testVersion { package = nominatim; }; + }; + + meta = { + description = "Search engine for OpenStreetMap data (DB, CLI)"; homepage = "https://nominatim.org/"; - license = licenses.gpl2Plus; - platforms = platforms.unix; - maintainers = [ maintainers.mausch ]; + license = lib.licenses.gpl2Plus; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ mausch ]; + teams = with lib.teams; [ + geospatial + ngi + ]; mainProgram = "nominatim"; }; } diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 35539f3ee485..dd42d408fd28 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -10250,6 +10250,8 @@ self: super: with self; { nominal-api-protos = callPackage ../development/python-modules/nominal-api-protos { }; + nominatim-api = callPackage ../by-name/no/nominatim/nominatim-api.nix { }; + nonbloat-db = callPackage ../development/python-modules/nonbloat-db { }; noneprompt = callPackage ../development/python-modules/noneprompt { };