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
41 postPatch = ''
42 substituteInPlace src/bindings/python/CMakeLists.txt \
43 --replace "\''${Python_SITEARCH}" "${placeholder "out"}/${python3.sitePackages}"
44 '';
45
46 nativeBuildInputs = [
47 cmake
48 pkg-config
49 ];
50
51 cmakeFlags = [
52 "-DENABLE_TESTS=OFF"
53 "-DENABLE_BENCHMARKS=OFF"
54 ];
55
56 env.NIX_CFLAGS_COMPILE = toString [
57 # Needed for date submodule with GCC 12 https://github.com/HowardHinnant/date/issues/750
58 "-Wno-error=stringop-overflow"
59 ];
60
61 buildInputs = [
62 boost
63 curl
64 geos
65 libspatialite
66 luajit
67 prime-server
68 protobuf
69 python3
70 sqlite
71 zeromq
72 zlib
73 ];
74
75 postFixup = ''
76 substituteInPlace "$out"/lib/pkgconfig/libvalhalla.pc \
77 --replace '=''${prefix}//' '=/' \
78 --replace '=''${exec_prefix}//' '=/'
79 '';
80
81 passthru.tests = {
82 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
83 };
84
85 meta = with lib; {
86 changelog = "https://github.com/valhalla/valhalla/blob/${finalAttrs.src.rev}/CHANGELOG.md";
87 description = "Open Source Routing Engine for OpenStreetMap";
88 homepage = "https://valhalla.readthedocs.io/";
89 license = licenses.mit;
90 maintainers = [ maintainers.Thra11 ];
91 platforms = platforms.linux;
92 };
93})