nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ stdenv, fetchFromGitHub, cmake, python, validatePkgConfig, fetchpatch }:
2
3stdenv.mkDerivation rec {
4 pname = "jsoncpp";
5 version = "1.9.2";
6
7 src = fetchFromGitHub {
8 owner = "open-source-parsers";
9 repo = "jsoncpp";
10 rev = version;
11 sha256 = "037d1b1qdmn3rksmn1j71j26bv4hkjv7sn7da261k853xb5899sg";
12 };
13
14 /* During darwin bootstrap, we have a cp that doesn't understand the
15 * --reflink=auto flag, which is used in the default unpackPhase for dirs
16 */
17 unpackPhase = ''
18 cp -a ${src} ${src.name}
19 chmod -R +w ${src.name}
20 export sourceRoot=${src.name}
21 '';
22
23 # Hack to be able to run the test, broken because we use
24 # CMAKE_SKIP_BUILD_RPATH to avoid cmake resetting rpath on install
25 preBuild = if stdenv.isDarwin then ''
26 export DYLD_LIBRARY_PATH="`pwd`/src/lib_json''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
27 '' else ''
28 export LD_LIBRARY_PATH="`pwd`/src/lib_json''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH"
29 '';
30
31 nativeBuildInputs = [ cmake python validatePkgConfig ];
32
33 patches = [
34 # Fix generation of pkg-config file (https://github.com/open-source-parsers/jsoncpp/pull/1199)
35 (fetchpatch {
36 url = "https://github.com/open-source-parsers/jsoncpp/commit/b05a21342a646a986b11c28ba6b19665756d21d2.patch";
37 sha256 = "0dn4cvvkcp9mnxbzyaqb49z6bv5yqsx1wlf1lyki1n2rni2hn63p";
38 })
39 ] ++ stdenv.lib.optionals (stdenv.isAarch64 || stdenv.isAarch32) [
40 # fix inverted sense in isAnyCharRequiredQuoting on arm. See: https://github.com/open-source-parsers/jsoncpp/pull/1120
41 (fetchpatch {
42 url = "https://github.com/open-source-parsers/jsoncpp/commit/9093358efae9e5981aa60013487fc7215f040a59.patch";
43 sha256 = "1wiqp70sck2md14sfc0zdkblqk9750cl55ykf9d6b9vs1ifzzzq5";
44 })
45 ];
46
47 cmakeFlags = [
48 "-DBUILD_SHARED_LIBS=ON"
49 "-DBUILD_STATIC_LIBS=OFF"
50 "-DJSONCPP_WITH_CMAKE_PACKAGE=ON"
51 ];
52
53 meta = with stdenv.lib; {
54 inherit version;
55 homepage = "https://github.com/open-source-parsers/jsoncpp";
56 description = "A C++ library for interacting with JSON.";
57 maintainers = with maintainers; [ ttuegel cpages nand0p ];
58 license = licenses.mit;
59 platforms = platforms.all;
60 };
61}