nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 fetchFromGitHub,
4 cmake,
5 copyPkgconfigItems,
6 makePkgconfigItem,
7 lib,
8 testers,
9 ctestCheckHook,
10 ninja,
11 double-conversion,
12}:
13stdenv.mkDerivation (finalAttrs: {
14 pname = "json.cpp";
15 version = "0-unstable-2025-10-25";
16
17 src = fetchFromGitHub {
18 owner = "jart";
19 repo = "json.cpp";
20 rev = "6ec4e44a5bbaadbe677473378c3d2133644c58a1";
21 hash = "sha256-kUFtyFPoHGCFWTGRD8SoBsqHYCplGPw/AcpMR9T0Ffk=";
22 };
23
24 doCheck = true;
25
26 cmakeFlags = [
27 (lib.cmakeBool "JSON_CPP_BUILD_TESTS" true)
28 (lib.cmakeBool "DOUBLE_CONVERSION_VENDORED" false)
29 (lib.cmakeBool "BUILD_SHARED_LIBS" stdenv.hostPlatform.hasSharedLibraries)
30 ];
31
32 nativeBuildInputs = [
33 cmake
34 copyPkgconfigItems
35 ctestCheckHook
36 ninja
37 ];
38
39 buildInputs = [
40 double-conversion
41 ];
42
43 outputs = [
44 "out"
45 "dev"
46 ];
47
48 passthru = {
49 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
50 };
51
52 # https://github.com/jart/json.cpp/issues/17
53 pkgconfigItems = [
54 (makePkgconfigItem rec {
55 name = "json.cpp";
56 inherit (finalAttrs) version;
57 cflags = [ "-I${variables.includedir}" ];
58 libs = [
59 "-L${variables.libdir}"
60 "-ljson"
61 ];
62 libsPrivate = [
63 # nixpkgs double-conversion does not support pkg-config
64 # as of yet.
65 "-ldouble-conversion"
66 ];
67 variables = {
68 includedir = "${placeholder "dev"}/include";
69 libdir = "${placeholder "out"}/lib";
70 };
71 inherit (finalAttrs.meta) description;
72 })
73 ];
74
75 meta = {
76 pkgConfigModules = [ "json.cpp" ];
77 description = "JSON for Classic C++";
78 homepage = "https://github.com/jart/json.cpp";
79 license = lib.licenses.asl20;
80 maintainers = with lib.maintainers; [ fzakaria ];
81 };
82})