1{ lib
2, stdenv
3, fetchFromGitHub
4, fetchpatch
5, cmake
6, pkg-config
7, boost
8, curl
9, geos
10, libspatialite
11, luajit
12, prime-server
13, protobuf
14, python3
15, sqlite
16, zeromq
17, zlib
18, testers
19}:
20
21stdenv.mkDerivation (finalAttrs: {
22 pname = "valhalla";
23 version = "3.4.0";
24
25 src = fetchFromGitHub {
26 owner = "valhalla";
27 repo = "valhalla";
28 rev = finalAttrs.version;
29 hash = "sha256-1X9vsWsgnzmXn7bCMhN2PNwtfV0RRdzRFZIrQN2PLfA=";
30 fetchSubmodules = true;
31 };
32
33 patches = [
34 # Fix build
35 (fetchpatch {
36 url = "https://github.com/valhalla/valhalla/commit/e4845b68e8ef8de9eabb359b23bf34c879e21f2b.patch";
37 hash = "sha256-xCufmXHGj1JxaMwm64JT9FPY+o0+x4glfJSYLdvHI8U=";
38 })
39
40 # Fix gcc-13 build:
41 # https://github.com/valhalla/valhalla/pull/4154
42 (fetchpatch {
43 name = "gcc-13.patch";
44 url = "https://github.com/valhalla/valhalla/commit/ed93f30272377cc6803533a1bb94fe81d14af81c.patch";
45 hash = "sha256-w4pnOqk/Jj3unVuesE64QSecrUIVSqwK69t9xNVc4GA=";
46 })
47 ];
48
49 postPatch = ''
50 substituteInPlace src/bindings/python/CMakeLists.txt \
51 --replace "\''${Python_SITEARCH}" "${placeholder "out"}/${python3.sitePackages}"
52 '';
53
54 nativeBuildInputs = [
55 cmake
56 pkg-config
57 ];
58
59 cmakeFlags = [
60 "-DENABLE_TESTS=OFF"
61 "-DENABLE_BENCHMARKS=OFF"
62 ];
63
64 env.NIX_CFLAGS_COMPILE = toString [
65 # Needed for date submodule with GCC 12 https://github.com/HowardHinnant/date/issues/750
66 "-Wno-error=stringop-overflow"
67 ];
68
69 buildInputs = [
70 boost
71 curl
72 geos
73 libspatialite
74 luajit
75 prime-server
76 protobuf
77 python3
78 sqlite
79 zeromq
80 zlib
81 ];
82
83 postFixup = ''
84 substituteInPlace "$out"/lib/pkgconfig/libvalhalla.pc \
85 --replace '=''${prefix}//' '=/' \
86 --replace '=''${exec_prefix}//' '=/'
87 '';
88
89 passthru.tests = {
90 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
91 };
92
93 meta = with lib; {
94 changelog = "https://github.com/valhalla/valhalla/blob/${finalAttrs.src.rev}/CHANGELOG.md";
95 description = "Open Source Routing Engine for OpenStreetMap";
96 homepage = "https://valhalla.readthedocs.io/";
97 license = licenses.mit;
98 maintainers = [ maintainers.Thra11 ];
99 pkgConfigModules = [ "libvalhalla" ];
100 platforms = platforms.linux;
101 };
102})