1{ lib, stdenv
2, fetchFromGitHub
3, cmake
4, expat
5, fmt
6, proj
7, bzip2
8, zlib
9, boost
10, cimg
11, postgresql
12, python3
13, withLuaJIT ? false
14, lua
15, luajit
16, libosmium
17, nlohmann_json
18, potrace
19, protozero
20, testers
21}:
22
23stdenv.mkDerivation (finalAttrs: {
24 pname = "osm2pgsql";
25 version = "1.9.2";
26
27 src = fetchFromGitHub {
28 owner = "osm2pgsql-dev";
29 repo = "osm2pgsql";
30 rev = finalAttrs.version;
31 hash = "sha256-RzJpaOEpgKm2IN6CK2Z67CUG0WU2ELvCpGhdQehjGKU=";
32 };
33
34 postPatch = ''
35 # Remove bundled libraries
36 rm -r contrib
37 '';
38
39 nativeBuildInputs = [ cmake ];
40
41 buildInputs = [
42 boost
43 bzip2
44 cimg
45 expat
46 fmt
47 libosmium
48 nlohmann_json
49 postgresql
50 potrace
51 proj
52 protozero
53 (python3.withPackages (p: with p; [ psycopg2 pyosmium ]))
54 zlib
55 ] ++ lib.optional withLuaJIT luajit
56 ++ lib.optional (!withLuaJIT) lua;
57
58 cmakeFlags = [
59 "-DEXTERNAL_LIBOSMIUM=ON"
60 "-DEXTERNAL_PROTOZERO=ON"
61 "-DEXTERNAL_FMT=ON"
62 ] ++ lib.optional withLuaJIT "-DWITH_LUAJIT:BOOL=ON";
63
64 installFlags = [ "install-gen" ];
65
66 passthru.tests.version = testers.testVersion {
67 package = finalAttrs.finalPackage;
68 };
69
70 meta = with lib; {
71 description = "OpenStreetMap data to PostgreSQL converter";
72 homepage = "https://osm2pgsql.org";
73 license = licenses.gpl2Plus;
74 platforms = platforms.unix;
75 maintainers = with maintainers; [ jglukasik das-g ];
76 };
77})