1{ lib, stdenv, fetchFromGitHub, fetchpatch, autoreconfHook }:
2
3stdenv.mkDerivation rec {
4 pname = "libpostal";
5 version = "1.1";
6
7 src = fetchFromGitHub {
8 owner = "openvenues";
9 repo = "libpostal";
10 rev = "v${version}";
11 sha256 = "sha256-gQTD2LQibaB2TK0SbzoILAljAGExURvDcF3C/TfDXqk=";
12 };
13
14 patches = [
15 # Fix darwin compilation with XCode 12 https://github.com/openvenues/libpostal/issues/511
16 (fetchpatch {
17 name = "Fix-C-compilation-macOS.patch";
18 url = "https://github.com/openvenues/libpostal/commit/9fcf066e38121b5c1439fc6bdc9a7e02234c8622.patch";
19 hash = "sha256-VpboGK+5sc1XrxMB051KWc8vP7Eu2g7zmTirzSaerns=";
20 })
21 # https://github.com/openvenues/libpostal/commit/bfdb6b8f87cc1cae9ba47870ff23deae0bb8ba51.patch
22 # with extra hunk removed so it applies
23 ./0001-test-adding-header-to-fix-warning.patch
24 ];
25
26 nativeBuildInputs = [ autoreconfHook ];
27
28 configureFlags = [
29 "--disable-data-download"
30 ] ++ lib.optionals stdenv.hostPlatform.isAarch64 [ "--disable-sse2" ];
31
32 meta = with lib; {
33 description = "C library for parsing/normalizing street addresses around the world. Powered by statistical NLP and open geo data";
34 homepage = "https://github.com/openvenues/libpostal";
35 license = licenses.mit;
36 maintainers = [ maintainers.Thra11 ];
37 mainProgram = "libpostal_data";
38 platforms = platforms.unix;
39 };
40}