libpostal: Optionally install data files and enable tests

Co-authored-by: Dmitry Bogatov <serenity@kaction.cc>
Co-authored-by: William <baduhai@proton.me>
This commit is contained in:
Dmitry Shachnev
2024-12-10 22:51:16 +03:00
co-authored by Dmitry Bogatov William
parent 7e2caa4db5
commit ea1978d543
2 changed files with 33 additions and 2 deletions
+29 -2
View File
@@ -1,6 +1,23 @@
{ lib, stdenv, fetchFromGitHub, autoreconfHook }:
{ lib, stdenv, fetchFromGitHub, fetchzip, autoreconfHook, withData ? false }:
stdenv.mkDerivation rec {
let
releases = "https://github.com/openvenues/libpostal/releases";
assets-base = fetchzip {
url = "${releases}/download/v1.0.0/libpostal_data.tar.gz";
hash = "sha256-FpGCkkRhVzyr08YcO0/iixxw0RK+3Of0sv/DH3GbbME=";
stripRoot = false;
};
assets-parser = fetchzip {
url = "${releases}/download/v1.0.0/parser.tar.gz";
hash = "sha256-OHETb3e0GtVS2b4DgklKDlrE/8gxF7XZ3FwmCTqZbqQ=";
stripRoot = false;
};
assets-language-classifier = fetchzip {
url = "${releases}/download/v1.0.0/language_classifier.tar.gz";
hash = "sha256-/Gn931Nx4UDBaiFUgGqC/NJUIKQ5aZT/+OYSlcfXva8=";
stripRoot = false;
};
in stdenv.mkDerivation rec {
pname = "libpostal";
version = "1.1";
@@ -17,6 +34,16 @@ stdenv.mkDerivation rec {
"--disable-data-download"
] ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "--disable-sse2" ];
postBuild = lib.optionalString withData ''
mkdir -p $out/share/libpostal
ln -s ${assets-language-classifier}/language_classifier $out/share/libpostal/language_classifier
ln -s ${assets-base}/transliteration $out/share/libpostal/transliteration
ln -s ${assets-base}/numex $out/share/libpostal/numex
ln -s ${assets-base}/address_expansions $out/share/libpostal/address_expansions
ln -s ${assets-parser}/address_parser $out/share/libpostal/address_parser
'';
doCheck = withData;
meta = with lib; {
description = "C library for parsing/normalizing street addresses around the world. Powered by statistical NLP and open geo data";
homepage = "https://github.com/openvenues/libpostal";
+4
View File
@@ -18865,4 +18865,8 @@ with pkgs;
biblioteca = callPackage ../by-name/bi/biblioteca/package.nix {
webkitgtk = webkitgtk_6_0;
};
libpostalWithData = callPackage ../by-name/li/libpostal/package.nix {
withData = true;
};
}