1{ stdenv, fetchurl, fetchpatch, findutils, fixDarwinDylibNames
2, sslSupport? true, openssl
3}:
4
5assert sslSupport -> openssl != null;
6
7stdenv.mkDerivation rec {
8 name = "libevent-${version}";
9 version = "2.1.8";
10
11 src = fetchurl {
12 url = "https://github.com/libevent/libevent/releases/download/release-${version}-stable/libevent-${version}-stable.tar.gz";
13 sha256 = "1hhxnxlr0fsdv7bdmzsnhdz16fxf3jg2r6vyljcl3kj6pflcap4n";
14 };
15
16 #NOTE: Patches to support libressl-2.7. These are taken from libevent upstream, and can both be dropped with the next release.
17 patches = [
18 (fetchpatch {
19 url = "https://github.com/libevent/libevent/commit/22dd14945c25600de3cf8b91000c66703b551e4f.patch";
20 sha256 = "0fzcb241cp9mm7j6baw22blcglbc083ryigzyjaij8r530av10kd";
21 })
22 (fetchpatch {
23 url = "https://github.com/libevent/libevent/commit/28b8075400c70b2d2da2ce07e590c2ec6d11783d.patch";
24 sha256 = "0dkzlk44033xksg2iq5w90r3lnziwl1mgz291nzqq906zrya0sdb";
25 })
26 ];
27
28 # libevent_openssl is moved into its own output, so that openssl isn't present
29 # in the default closure.
30 outputs = [ "out" "dev" ]
31 ++ stdenv.lib.optional sslSupport "openssl"
32 ;
33 outputBin = "dev";
34 propagatedBuildOutputs = [ "out" ]
35 ++ stdenv.lib.optional sslSupport "openssl"
36 ;
37
38 buildInputs = []
39 ++ stdenv.lib.optional sslSupport openssl
40 ++ stdenv.lib.optional stdenv.isCygwin findutils
41 ++ stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames
42 ;
43
44 doCheck = false; # needs the net
45
46 postInstall = stdenv.lib.optionalString sslSupport ''
47 moveToOutput "lib/libevent_openssl*" "$openssl"
48 substituteInPlace "$dev/lib/pkgconfig/libevent_openssl.pc" \
49 --replace "$out" "$openssl"
50 sed "/^libdir=/s|$out|$openssl|" -i "$openssl"/lib/libevent_openssl.la
51 '';
52
53 enableParallelBuilding = true;
54
55 meta = with stdenv.lib; {
56 description = "Event notification library";
57 longDescription = ''
58 The libevent API provides a mechanism to execute a callback function
59 when a specific event occurs on a file descriptor or after a timeout
60 has been reached. Furthermore, libevent also support callbacks due
61 to signals or regular timeouts.
62
63 libevent is meant to replace the event loop found in event driven
64 network servers. An application just needs to call event_dispatch()
65 and then add or remove events dynamically without having to change
66 the event loop.
67 '';
68 homepage = http://libevent.org/;
69 license = licenses.bsd3;
70 platforms = platforms.all;
71 };
72}