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
|
{ lib
, asioSupport ? true
, asio
, boost180
, log4cxxSupport ? false
, log4cxx
, snappySupport ? false
, snappy
, zlibSupport ? true
, zlib
, zstdSupport ? true
, zstd
, gtest
, gtestSupport ? false
, cmake
, curl
, fetchFromGitHub
, protobuf
, 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";
defaultOptionals = [ protobuf ]
++ lib.optional snappySupport snappy.dev
++ lib.optional zlibSupport zlib
++ lib.optional zstdSupport zstd
++ lib.optional log4cxxSupport log4cxx
++ lib.optional asioSupport asio
++ lib.optional (!asioSupport) boost180;
in
stdenv.mkDerivation (finalAttrs: rec {
pname = "libpulsar";
version = "3.5.0";
src = fetchFromGitHub {
owner = "apache";
repo = "pulsar-client-cpp";
rev = "v${version}";
hash = "sha256-pNeoStDryyMtBolpp5nT5GFjYPuXg2ks1Ka1mjjN/9k=";
};
nativeBuildInputs = [ cmake pkg-config ]
++ defaultOptionals
++ lib.optional gtestSupport gtest.dev;
buildInputs = [ jsoncpp openssl curl ]
++ defaultOptionals;
cmakeFlags = [
"-DBUILD_TESTS=${enableCmakeFeature gtestSupport}"
"-DUSE_LOG4CXX=${enableCmakeFeature log4cxxSupport}"
"-DUSE_ASIO=${enableCmakeFeature asioSupport}"
];
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/next/client-libraries-cpp/";
description = "Apache Pulsar C++ library";
changelog = "https://github.com/apache/pulsar-client-cpp/releases/tag/v${version}";
platforms = platforms.all;
license = licenses.asl20;
maintainers = with maintainers; [ corbanr gaelreyrol ];
};
})
|