nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 cmake,
6 doxygen,
7 graphviz,
8 gtest,
9 unstableGitUpdater,
10 valgrind,
11}:
12
13stdenv.mkDerivation (finalAttrs: {
14 pname = "rapidjson";
15 version = "1.1.0-unstable-2025-02-05";
16
17 outputs = [
18 "out"
19 "doc"
20 ];
21
22 src = fetchFromGitHub {
23 owner = "Tencent";
24 repo = "rapidjson";
25 rev = "24b5e7a8b27f42fa16b96fc70aade9106cf7102f";
26 hash = "sha256-oHHLYRDMb7Y/k0CwsdsxPC5lglr2IChQi0AiOMiFn78=";
27 };
28
29 patches = [
30 ./use-nixpkgs-gtest.patch
31 # https://github.com/Tencent/rapidjson/issues/2214
32 ./suppress-valgrind-failures.patch
33
34 # disable tests which don't build on clang-19
35 # https://github.com/Tencent/rapidjson/issues/2318
36 ./char_traits-clang-19-errors.diff
37 ];
38
39 postPatch = ''
40 for f in doc/Doxyfile.*; do
41 substituteInPlace $f \
42 --replace-fail "WARN_IF_UNDOCUMENTED = YES" "WARN_IF_UNDOCUMENTED = NO"
43 done
44 '';
45
46 nativeBuildInputs = [
47 cmake
48 doxygen
49 graphviz
50 ];
51
52 buildInputs = [
53 gtest
54 ];
55
56 strictDeps = true;
57
58 cmakeFlags = [
59 (lib.cmakeBool "RAPIDJSON_BUILD_DOC" true)
60 (lib.cmakeBool "RAPIDJSON_BUILD_TESTS" true)
61 (lib.cmakeBool "RAPIDJSON_BUILD_EXAMPLES" true)
62 # gtest 1.13+ requires C++14 or later.
63 (lib.cmakeBool "RAPIDJSON_BUILD_CXX11" false)
64 (lib.cmakeBool "RAPIDJSON_BUILD_CXX17" true)
65 # Prevent -march=native
66 (lib.cmakeBool "RAPIDJSON_ENABLE_INSTRUMENTATION_OPT" false)
67 # Disable -Werror by using build type specific flags, which are
68 # added after general CMAKE_CXX_FLAGS.
69 (lib.cmakeFeature "CMAKE_CXX_FLAGS_RELEASE" "-Wno-error")
70 ];
71
72 doCheck = !(stdenv.hostPlatform.isStatic || stdenv.hostPlatform.isDarwin);
73
74 nativeCheckInputs = [
75 valgrind
76 ];
77
78 passthru = {
79 updateScript = unstableGitUpdater {
80 tagPrefix = "v";
81 };
82 };
83
84 meta = {
85 description = "Fast JSON parser/generator for C++ with both SAX/DOM style API";
86 homepage = "http://rapidjson.org/";
87 license = lib.licenses.mit;
88 platforms = lib.platforms.unix;
89 maintainers = [
90 lib.maintainers.dotlambda
91 lib.maintainers.Madouura
92 lib.maintainers.tobim
93 ];
94 };
95})