at 24.11-pre 2.9 kB view raw
1{ useLua ? true 2, usePcre ? true 3, withPrometheusExporter ? true 4, sslLibrary ? "quictls" 5, stdenv 6, lib 7, fetchurl 8, nixosTests 9, zlib 10, libxcrypt 11, wolfssl 12, libressl 13, quictls 14, openssl 15, lua5_4 16, pcre2 17, systemd 18}: 19 20assert lib.assertOneOf "sslLibrary" sslLibrary [ "quictls" "openssl" "libressl" "wolfssl" ]; 21let 22 sslPkgs = { 23 inherit quictls openssl libressl; 24 wolfssl = wolfssl.override { 25 variant = "haproxy"; 26 extraConfigureFlags = [ "--enable-quic" ]; 27 }; 28 }; 29 sslPkg = sslPkgs.${sslLibrary}; 30in stdenv.mkDerivation (finalAttrs: { 31 pname = "haproxy"; 32 version = "2.9.7"; 33 34 src = fetchurl { 35 url = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/haproxy-${finalAttrs.version}.tar.gz"; 36 hash = "sha256-0aClbwCKjS8Ae8DDffaylSUg0fTd4zuNOAJxDlFYwTE="; 37 }; 38 39 buildInputs = [ sslPkg zlib libxcrypt ] 40 ++ lib.optional useLua lua5_4 41 ++ lib.optional usePcre pcre2 42 ++ lib.optional stdenv.isLinux systemd; 43 44 # TODO: make it work on bsd as well 45 makeFlags = [ 46 "PREFIX=${placeholder "out"}" 47 ("TARGET=" + (if stdenv.isSunOS then "solaris" 48 else if stdenv.isLinux then "linux-glibc" 49 else if stdenv.isDarwin then "osx" 50 else "generic")) 51 ]; 52 53 buildFlags = [ 54 "USE_ZLIB=yes" 55 "USE_OPENSSL=yes" 56 "SSL_INC=${lib.getDev sslPkg}/include" 57 "SSL_LIB=${lib.getDev sslPkg}/lib" 58 "USE_QUIC=yes" 59 ] ++ lib.optionals (sslLibrary == "openssl") [ 60 "USE_QUIC_OPENSSL_COMPAT=yes" 61 ] ++ lib.optionals (sslLibrary == "wolfssl") [ 62 "USE_OPENSSL_WOLFSSL=yes" 63 ] ++ lib.optionals usePcre [ 64 "USE_PCRE2=yes" 65 "USE_PCRE2_JIT=yes" 66 ] ++ lib.optionals useLua [ 67 "USE_LUA=yes" 68 "LUA_LIB_NAME=lua" 69 "LUA_LIB=${lua5_4}/lib" 70 "LUA_INC=${lua5_4}/include" 71 ] ++ lib.optionals stdenv.isLinux [ 72 "USE_SYSTEMD=yes" 73 "USE_GETADDRINFO=1" 74 ] ++ lib.optionals withPrometheusExporter [ 75 "USE_PROMEX=yes" 76 ] ++ [ "CC=${stdenv.cc.targetPrefix}cc" ]; 77 78 enableParallelBuilding = true; 79 80 passthru.tests.haproxy = nixosTests.haproxy; 81 82 meta = { 83 changelog = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/CHANGELOG"; 84 description = "Reliable, high performance TCP/HTTP load balancer"; 85 homepage = "https://haproxy.org"; 86 license = with lib.licenses; [ gpl2Plus lgpl21Only ]; 87 longDescription = '' 88 HAProxy is a free, very fast and reliable solution offering high 89 availability, load balancing, and proxying for TCP and HTTP-based 90 applications. It is particularly suited for web sites crawling under very 91 high loads while needing persistence or Layer7 processing. Supporting 92 tens of thousands of connections is clearly realistic with todays 93 hardware. 94 ''; 95 maintainers = with lib.maintainers; [ vifino ]; 96 platforms = with lib.platforms; linux ++ darwin; 97 mainProgram = "haproxy"; 98 }; 99})