2023-07-15 17:15:38 +00:00
|
|
|
{ useLua ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
, usePcre ? true
|
|
|
|
, withPrometheusExporter ? true
|
2024-01-25 14:12:00 +00:00
|
|
|
, sslLibrary ? "quictls"
|
2023-08-04 22:07:22 +00:00
|
|
|
, stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
, nixosTests
|
|
|
|
, zlib
|
|
|
|
, libxcrypt
|
2024-01-25 14:12:00 +00:00
|
|
|
, wolfssl
|
|
|
|
, libressl
|
|
|
|
, quictls
|
|
|
|
, openssl
|
|
|
|
, lua5_4
|
|
|
|
, pcre2
|
|
|
|
, systemd
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
assert lib.assertOneOf "sslLibrary" sslLibrary [ "quictls" "openssl" "libressl" "wolfssl" ];
|
|
|
|
let
|
|
|
|
sslPkgs = {
|
|
|
|
inherit quictls openssl libressl;
|
|
|
|
wolfssl = wolfssl.override {
|
|
|
|
variant = "haproxy";
|
|
|
|
extraConfigureFlags = [ "--enable-quic" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
sslPkg = sslPkgs.${sslLibrary};
|
2024-01-13 08:15:51 +00:00
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "haproxy";
|
2024-02-07 01:22:34 +00:00
|
|
|
version = "2.9.4";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2023-08-04 22:07:22 +00:00
|
|
|
url = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/haproxy-${finalAttrs.version}.tar.gz";
|
2024-02-07 01:22:34 +00:00
|
|
|
hash = "sha256-nDiSzDwISsTwASXvIqFRzxgUFthKqKN69q9qoDmQlrw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
buildInputs = [ sslPkg zlib libxcrypt ]
|
2024-01-25 14:12:00 +00:00
|
|
|
++ lib.optional useLua lua5_4
|
|
|
|
++ lib.optional usePcre pcre2
|
2020-04-24 23:36:52 +00:00
|
|
|
++ lib.optional stdenv.isLinux systemd;
|
|
|
|
|
|
|
|
# TODO: make it work on bsd as well
|
|
|
|
makeFlags = [
|
2022-03-10 19:12:11 +00:00
|
|
|
"PREFIX=${placeholder "out"}"
|
2023-08-04 22:07:22 +00:00
|
|
|
("TARGET=" + (if stdenv.isSunOS then "solaris"
|
|
|
|
else if stdenv.isLinux then "linux-glibc"
|
|
|
|
else if stdenv.isDarwin then "osx"
|
|
|
|
else "generic"))
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildFlags = [
|
|
|
|
"USE_ZLIB=yes"
|
2024-01-25 14:12:00 +00:00
|
|
|
"USE_OPENSSL=yes"
|
|
|
|
"SSL_INC=${lib.getDev sslPkg}/include"
|
|
|
|
"SSL_LIB=${lib.getDev sslPkg}/lib"
|
|
|
|
"USE_QUIC=yes"
|
|
|
|
] ++ lib.optionals (sslLibrary == "openssl") [
|
|
|
|
"USE_QUIC_OPENSSL_COMPAT=yes"
|
|
|
|
] ++ lib.optionals (sslLibrary == "wolfssl") [
|
|
|
|
"USE_OPENSSL_WOLFSSL=yes"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals usePcre [
|
2024-01-25 14:12:00 +00:00
|
|
|
"USE_PCRE2=yes"
|
|
|
|
"USE_PCRE2_JIT=yes"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals useLua [
|
|
|
|
"USE_LUA=yes"
|
2021-05-20 23:08:51 +00:00
|
|
|
"LUA_LIB_NAME=lua"
|
2024-01-25 14:12:00 +00:00
|
|
|
"LUA_LIB=${lua5_4}/lib"
|
|
|
|
"LUA_INC=${lua5_4}/include"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
"USE_SYSTEMD=yes"
|
|
|
|
"USE_GETADDRINFO=1"
|
|
|
|
] ++ lib.optionals withPrometheusExporter [
|
2022-02-10 20:34:41 +00:00
|
|
|
"USE_PROMEX=yes"
|
2021-02-19 19:06:45 +00:00
|
|
|
] ++ [ "CC=${stdenv.cc.targetPrefix}cc" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-11-15 13:44:38 +00:00
|
|
|
passthru.tests.haproxy = nixosTests.haproxy;
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
meta = {
|
|
|
|
changelog = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/CHANGELOG";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Reliable, high performance TCP/HTTP load balancer";
|
2023-08-04 22:07:22 +00:00
|
|
|
homepage = "https://haproxy.org";
|
|
|
|
license = with lib.licenses; [ gpl2Plus lgpl21Only ];
|
2020-04-24 23:36:52 +00:00
|
|
|
longDescription = ''
|
|
|
|
HAProxy is a free, very fast and reliable solution offering high
|
|
|
|
availability, load balancing, and proxying for TCP and HTTP-based
|
|
|
|
applications. It is particularly suited for web sites crawling under very
|
|
|
|
high loads while needing persistence or Layer7 processing. Supporting
|
|
|
|
tens of thousands of connections is clearly realistic with todays
|
|
|
|
hardware.
|
|
|
|
'';
|
2024-01-25 14:12:00 +00:00
|
|
|
maintainers = with lib.maintainers; [ vifino ];
|
2023-08-04 22:07:22 +00:00
|
|
|
platforms = with lib.platforms; linux ++ darwin;
|
2023-10-09 19:29:22 +00:00
|
|
|
mainProgram = "haproxy";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-08-04 22:07:22 +00:00
|
|
|
})
|