1{ useLua ? !stdenv.isDarwin
2, usePcre ? true
3, stdenv, fetchurl
4, openssl, zlib, lua5_3 ? null, pcre ? null
5}:
6
7assert useLua -> lua5_3 != null;
8assert usePcre -> pcre != null;
9
10stdenv.mkDerivation rec {
11 pname = "haproxy";
12 version = "1.8.4";
13 name = "${pname}-${version}";
14
15 src = fetchurl {
16 url = "https://www.haproxy.org/download/${stdenv.lib.versions.majorMinor version}/src/${name}.tar.gz";
17 sha256 = "19l4i0p92ahm3vaw42gz3rmmidfivk36mvqyhir81h6ywyjb01g3";
18 };
19
20 buildInputs = [ openssl zlib ]
21 ++ stdenv.lib.optional useLua lua5_3
22 ++ stdenv.lib.optional usePcre pcre;
23
24 # TODO: make it work on bsd as well
25 makeFlags = [
26 "PREFIX=\${out}"
27 ("TARGET=" + (if stdenv.isSunOS then "solaris"
28 else if stdenv.isLinux then "linux2628"
29 else if stdenv.isDarwin then "osx"
30 else "generic"))
31 ];
32 buildFlags = [
33 "USE_OPENSSL=yes"
34 "USE_ZLIB=yes"
35 ] ++ stdenv.lib.optionals usePcre [
36 "USE_PCRE=yes"
37 "USE_PCRE_JIT=yes"
38 ] ++ stdenv.lib.optionals useLua [
39 "USE_LUA=yes"
40 "LUA_LIB=${lua5_3}/lib"
41 "LUA_INC=${lua5_3}/include"
42 ] ++ stdenv.lib.optional stdenv.isDarwin "CC=cc";
43
44 meta = {
45 description = "Reliable, high performance TCP/HTTP load balancer";
46 longDescription = ''
47 HAProxy is a free, very fast and reliable solution offering high
48 availability, load balancing, and proxying for TCP and HTTP-based
49 applications. It is particularly suited for web sites crawling under very
50 high loads while needing persistence or Layer7 processing. Supporting
51 tens of thousands of connections is clearly realistic with todays
52 hardware.
53 '';
54 homepage = http://haproxy.1wt.eu;
55 maintainers = with stdenv.lib.maintainers; [ fuzzy-id garbas ];
56 platforms = with stdenv.lib.platforms; linux ++ darwin;
57 license = stdenv.lib.licenses.gpl2;
58 };
59}