easytier: 2.1.1 -> 2.1.2 (#376259)
[NixPkgs.git] / pkgs / by-name / li / libpostal / package.nix
blob74b0402e04f94d632e5916979fd036f41bae9aeb
1 { lib, stdenv, fetchFromGitHub, fetchzip, autoreconfHook, withData ? false }:
3 let
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=";
8     stripRoot = false;
9   };
10   assets-parser = fetchzip {
11     url = "${releases}/download/v1.0.0/parser.tar.gz";
12     hash = "sha256-OHETb3e0GtVS2b4DgklKDlrE/8gxF7XZ3FwmCTqZbqQ=";
13     stripRoot = false;
14   };
15   assets-language-classifier = fetchzip {
16     url = "${releases}/download/v1.0.0/language_classifier.tar.gz";
17     hash = "sha256-/Gn931Nx4UDBaiFUgGqC/NJUIKQ5aZT/+OYSlcfXva8=";
18     stripRoot = false;
19   };
20 in stdenv.mkDerivation rec {
21   pname = "libpostal";
22   version = "1.1";
24   src = fetchFromGitHub {
25     owner = "openvenues";
26     repo = "libpostal";
27     tag = "v${version}";
28     hash = "sha256-7G/CjYdVzsrvUFXGODoXgXoRp8txkl5SddcPtgltrjY=";
29   };
31   nativeBuildInputs = [ autoreconfHook ];
33   configureFlags = [
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
44   '';
45   doCheck = withData;
47   meta = with lib; {
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;
54   };