1 { lib, stdenv, fetchFromGitHub, fetchzip, autoreconfHook, withData ? false }:
4 releases = "https://github.com/openvenues/libpostal/releases";
5 assets-base = fetchzip {
6 url = "${releases}/download/v1.0.0/libpostal_data.tar.gz";
7 hash = "sha256-FpGCkkRhVzyr08YcO0/iixxw0RK+3Of0sv/DH3GbbME=";
10 assets-parser = fetchzip {
11 url = "${releases}/download/v1.0.0/parser.tar.gz";
12 hash = "sha256-OHETb3e0GtVS2b4DgklKDlrE/8gxF7XZ3FwmCTqZbqQ=";
15 assets-language-classifier = fetchzip {
16 url = "${releases}/download/v1.0.0/language_classifier.tar.gz";
17 hash = "sha256-/Gn931Nx4UDBaiFUgGqC/NJUIKQ5aZT/+OYSlcfXva8=";
20 in stdenv.mkDerivation rec {
24 src = fetchFromGitHub {
28 hash = "sha256-7G/CjYdVzsrvUFXGODoXgXoRp8txkl5SddcPtgltrjY=";
31 nativeBuildInputs = [ autoreconfHook ];
34 "--disable-data-download"
35 ] ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "--disable-sse2" ];
37 postBuild = lib.optionalString withData ''
38 mkdir -p $out/share/libpostal
39 ln -s ${assets-language-classifier}/language_classifier $out/share/libpostal/language_classifier
40 ln -s ${assets-base}/transliteration $out/share/libpostal/transliteration
41 ln -s ${assets-base}/numex $out/share/libpostal/numex
42 ln -s ${assets-base}/address_expansions $out/share/libpostal/address_expansions
43 ln -s ${assets-parser}/address_parser $out/share/libpostal/address_parser
48 description = "C library for parsing/normalizing street addresses around the world. Powered by statistical NLP and open geo data";
49 homepage = "https://github.com/openvenues/libpostal";
50 license = licenses.mit;
51 maintainers = [ maintainers.Thra11 ];
52 mainProgram = "libpostal_data";
53 platforms = platforms.unix;