1{ useLua ? true
2, usePcre ? true
3, withPrometheusExporter ? true
4, stdenv
5, lib
6, fetchurl
7, nixosTests
8, openssl
9, zlib
10, libxcrypt
11, lua5_3 ? null
12, pcre ? null
13, systemd ? null
14}:
15
16assert useLua -> lua5_3 != null;
17assert usePcre -> pcre != null;
18
19stdenv.mkDerivation (finalAttrs: {
20 pname = "haproxy";
21 version = "2.8.4";
22
23 src = fetchurl {
24 url = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/haproxy-${finalAttrs.version}.tar.gz";
25 hash = "sha256-gbrL9Q7G0Pfsqq18A+WZeLADIvva1u1KmJ3TF1S28l0=";
26 };
27
28 buildInputs = [ openssl zlib libxcrypt ]
29 ++ lib.optional useLua lua5_3
30 ++ lib.optional usePcre pcre
31 ++ lib.optional stdenv.isLinux systemd;
32
33 # TODO: make it work on bsd as well
34 makeFlags = [
35 "PREFIX=${placeholder "out"}"
36 ("TARGET=" + (if stdenv.isSunOS then "solaris"
37 else if stdenv.isLinux then "linux-glibc"
38 else if stdenv.isDarwin then "osx"
39 else "generic"))
40 ];
41
42 buildFlags = [
43 "USE_OPENSSL=yes"
44 "USE_ZLIB=yes"
45 ] ++ lib.optionals usePcre [
46 "USE_PCRE=yes"
47 "USE_PCRE_JIT=yes"
48 ] ++ lib.optionals useLua [
49 "USE_LUA=yes"
50 "LUA_LIB_NAME=lua"
51 "LUA_LIB=${lua5_3}/lib"
52 "LUA_INC=${lua5_3}/include"
53 ] ++ lib.optionals stdenv.isLinux [
54 "USE_SYSTEMD=yes"
55 "USE_GETADDRINFO=1"
56 ] ++ lib.optionals withPrometheusExporter [
57 "USE_PROMEX=yes"
58 ] ++ [ "CC=${stdenv.cc.targetPrefix}cc" ];
59
60 enableParallelBuilding = true;
61
62 passthru.tests.haproxy = nixosTests.haproxy;
63
64 meta = {
65 changelog = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/CHANGELOG";
66 description = "Reliable, high performance TCP/HTTP load balancer";
67 homepage = "https://haproxy.org";
68 license = with lib.licenses; [ gpl2Plus lgpl21Only ];
69 longDescription = ''
70 HAProxy is a free, very fast and reliable solution offering high
71 availability, load balancing, and proxying for TCP and HTTP-based
72 applications. It is particularly suited for web sites crawling under very
73 high loads while needing persistence or Layer7 processing. Supporting
74 tens of thousands of connections is clearly realistic with todays
75 hardware.
76 '';
77 maintainers = with lib.maintainers; [ ];
78 platforms = with lib.platforms; linux ++ darwin;
79 mainProgram = "haproxy";
80 };
81})