lol
1{ stdenv
2, lib
3, fetchFromGitHub
4, cmake
5}:
6let
7 testData = fetchFromGitHub {
8 owner = "nlohmann";
9 repo = "json_test_data";
10 rev = "v3.1.0";
11 hash = "sha256-bG34W63ew7haLnC82A3lS7bviPDnApLipaBjJAjLcVk=";
12 };
13in stdenv.mkDerivation (finalAttrs: {
14 pname = "nlohmann_json";
15 version = "3.11.3";
16
17 src = fetchFromGitHub {
18 owner = "nlohmann";
19 repo = "json";
20 rev = "v${finalAttrs.version}";
21 hash = "sha256-7F0Jon+1oWL7uqet5i1IgHX0fUw/+z0QwEcA3zs5xHg=";
22 };
23
24 nativeBuildInputs = [ cmake ];
25
26 cmakeFlags = [
27 "-DJSON_BuildTests=${if finalAttrs.finalPackage.doCheck then "ON" else "OFF"}"
28 "-DJSON_FastTests=ON"
29 "-DJSON_MultipleHeaders=ON"
30 ] ++ lib.optional finalAttrs.finalPackage.doCheck "-DJSON_TestDataDirectory=${testData}";
31
32 doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
33
34 # skip tests that require git or modify “installed files”
35 preCheck = ''
36 checkFlagsArray+=("ARGS=-LE 'not_reproducible|git_required'")
37 '';
38
39 postInstall = "rm -rf $out/lib64";
40
41 meta = with lib; {
42 description = "JSON for Modern C++";
43 homepage = "https://json.nlohmann.me";
44 changelog = "https://github.com/nlohmann/json/blob/develop/ChangeLog.md";
45 license = licenses.mit;
46 platforms = platforms.all;
47 };
48})