1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 pkg-config,
6 cmake,
7 argtable,
8 catch2,
9 curl,
10 doxygen,
11 hiredis,
12 jsoncpp,
13 libmicrohttpd,
14}:
15
16stdenv.mkDerivation rec {
17 pname = "libjson-rpc-cpp";
18 version = "1.4.1";
19
20 src = fetchFromGitHub {
21 owner = "cinemast";
22 repo = "libjson-rpc-cpp";
23 sha256 = "sha256-YCCZN4y88AixQeo24pk6YHfSCsJz8jJ97Dg40KM08cQ=";
24 rev = "v${version}";
25 };
26
27 env.NIX_CFLAGS_COMPILE = "-I${catch2}/include/catch2";
28
29 nativeBuildInputs = [
30 pkg-config
31 cmake
32 doxygen
33 ];
34
35 buildInputs = [
36 argtable
37 catch2
38 curl
39 hiredis
40 jsoncpp
41 libmicrohttpd
42 ];
43
44 postPatch = ''
45 for f in cmake/FindArgtable.cmake \
46 src/stubgenerator/stubgenerator.cpp \
47 src/stubgenerator/stubgeneratorfactory.cpp
48 do
49 sed -i -re 's/argtable2/argtable3/g' $f
50 done
51
52 sed -i -re 's#MATCHES "jsoncpp"#MATCHES ".*/jsoncpp/json$"#g' cmake/FindJsoncpp.cmake
53 '';
54
55 preConfigure = ''
56 mkdir -p Build/Install
57 pushd Build
58 '';
59
60 # this hack is needed because the cmake scripts
61 # require write permission to absolute paths
62 configurePhase = ''
63 runHook preConfigure
64 cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/Install \
65 -DCMAKE_BUILD_TYPE=Release
66 runHook postConfigure
67 '';
68
69 preInstall = ''
70 function fixRunPath {
71 p=$(patchelf --print-rpath $1)
72 q="$p:${
73 lib.makeLibraryPath [
74 jsoncpp
75 argtable
76 libmicrohttpd
77 curl
78 ]
79 }:$out/lib"
80 patchelf --set-rpath $q $1
81 }
82
83 mkdir -p $out
84 '';
85
86 postInstall = ''
87 sed -i -re "s#-([LI]).*/Build/Install(.*)#-\1$out\2#g" Install/lib64/pkgconfig/*.pc
88 for f in Install/lib64/*.so* $(find Install/bin -executable -type f); do
89 fixRunPath $f
90 done
91 cp -r Install/* $out
92 '';
93
94 installPhase = ''
95 runHook preInstall
96 make install
97 runHook postInstall
98 '';
99
100 meta = with lib; {
101 description = "C++ framework for json-rpc (json remote procedure call)";
102 mainProgram = "jsonrpcstub";
103 homepage = "https://github.com/cinemast/libjson-rpc-cpp";
104 license = licenses.mit;
105 platforms = platforms.linux;
106 sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
107 maintainers = with maintainers; [ robertrichter ];
108 };
109}