1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
{ lib
, clang-tools
, llvmPackages
, boost179
, protobuf
, python3Support ? false
, python3
, log4cxxSupport ? false
, log4cxx
, snappySupport ? false
, snappy
, zlibSupport ? true
, zlib
, zstdSupport ? true
, zstd
, gtest
, gtestSupport ? false
, cmake
, curl
, fetchurl
, jsoncpp
, openssl
, pkg-config
, stdenv
}:
let
/*
Check if null or false
Example:
let result = enableFeature null
=> "OFF"
let result = enableFeature false
=> "OFF"
let result = enableFeature «derivation»
=> "ON"
*/
enableCmakeFeature = p: if (p == null || p == false) then "OFF" else "ON";
# Not really sure why I need to do this.. If I call clang-tools without the override it defaults to a different version and fails
clangTools = clang-tools.override { inherit stdenv llvmPackages; };
# If boost has python enabled, then boost-python package will be installed which is used by libpulsars python wrapper
boost = if python3Support then boost179.override { inherit stdenv; enablePython = python3Support; python = python3; } else boost179;
defaultOptionals = [ boost protobuf ]
++ lib.optional python3Support python3
++ lib.optional snappySupport snappy.dev
++ lib.optional zlibSupport zlib
++ lib.optional zstdSupport zstd
++ lib.optional log4cxxSupport log4cxx;
in
stdenv.mkDerivation rec {
pname = "libpulsar";
version = "2.10.2";
src = fetchurl {
hash = "sha256-IONnsSDbnX2qz+Xya0taHYSViTOiRI36AfcxmY3dNpo=";
url = "mirror://apache/pulsar/pulsar-${version}/apache-pulsar-${version}-src.tar.gz";
};
sourceRoot = "apache-pulsar-${version}-src/pulsar-client-cpp";
# clang-tools needed for clang-format
nativeBuildInputs = [ cmake pkg-config clangTools ]
++ defaultOptionals
++ lib.optional gtestSupport gtest.dev;
buildInputs = [ jsoncpp openssl curl ]
++ defaultOptionals;
# Needed for GCC on Linux
env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=return-type" ];
cmakeFlags = [
"-DBUILD_TESTS=${enableCmakeFeature gtestSupport}"
"-DBUILD_PYTHON_WRAPPER=${enableCmakeFeature python3Support}"
"-DUSE_LOG4CXX=${enableCmakeFeature log4cxxSupport}"
"-DClangTools_PATH=${clangTools}/bin"
];
enableParallelBuilding = true;
doInstallCheck = true;
installCheckPhase = ''
echo ${lib.escapeShellArg ''
#include <pulsar/Client.h>
int main (int argc, char **argv) {
pulsar::Client client("pulsar://localhost:6650");
return 0;
}
''} > test.cc
$CXX test.cc -L $out/lib -I $out/include -lpulsar -o test
'';
meta = with lib; {
homepage = "https://pulsar.apache.org/docs/en/client-libraries-cpp";
description = "Apache Pulsar C++ library";
platforms = platforms.all;
license = licenses.asl20;
maintainers = [ maintainers.corbanr ];
};
}
|