1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 pkg-config,
7 apacheHttpd,
8 apr,
9 aprutil,
10 curl,
11 db,
12 fcgi,
13 gdal,
14 geos,
15 gfortran,
16 libgeotiff,
17 libjpeg,
18 libpng,
19 libtiff,
20 pcre2,
21 pixman,
22 proj,
23 sqlite,
24 zlib,
25}:
26
27stdenv.mkDerivation (finalAttrs: {
28 pname = "mapcache";
29 version = "1.14.1";
30
31 src = fetchFromGitHub {
32 owner = "MapServer";
33 repo = "mapcache";
34 tag = "rel-${lib.replaceStrings [ "." ] [ "-" ] finalAttrs.version}";
35 hash = "sha256-AwdZdOEq9SZ5VzuBllg4U1gdVxZ9IVdqiDrn3QuRdCk=";
36 };
37
38 nativeBuildInputs = [
39 cmake
40 pkg-config
41 ]
42 ++ lib.optionals stdenv.hostPlatform.isDarwin [
43 # work around for `ld: file not found: @rpath/libquadmath.0.dylib`
44 gfortran.cc
45 ];
46
47 buildInputs = [
48 apacheHttpd
49 apr
50 aprutil
51 curl
52 db
53 fcgi
54 gdal
55 geos
56 libgeotiff
57 libjpeg
58 libpng
59 libtiff
60 pcre2
61 pixman
62 proj
63 sqlite
64 zlib
65 ];
66
67 cmakeFlags = [
68 (lib.cmakeBool "WITH_BERKELEY_DB" true)
69 (lib.cmakeBool "WITH_MEMCACHE" true)
70 (lib.cmakeBool "WITH_TIFF" true)
71 (lib.cmakeBool "WITH_GEOTIFF" true)
72 (lib.cmakeBool "WITH_PCRE2" true)
73 (lib.cmakeFeature "APACHE_MODULE_DIR" "${placeholder "out"}/modules")
74 ];
75
76 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin "-std=c99";
77
78 prePatch = lib.optionalString stdenv.hostPlatform.isDarwin ''
79 substituteInPlace CMakeLists.txt \
80 --replace-fail "include_directories(\''${TIFF_INCLUDE_DIR})" "" \
81 --replace-fail "target_link_libraries(mapcache \''${TIFF_LIBRARY})" "target_link_libraries(mapcache TIFF::TIFF)"
82 '';
83
84 meta = {
85 description = "Server that implements tile caching to speed up access to WMS layers";
86 homepage = "https://mapserver.org/mapcache/";
87 changelog = "https://www.mapserver.org/development/changelog/mapcache/";
88 license = lib.licenses.mit;
89 teams = [ lib.teams.geospatial ];
90 platforms = lib.platforms.unix;
91 };
92})