2023-07-15 17:15:38 +00:00
|
|
|
{ useLua ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
, usePcre ? true
|
2024-01-13 08:15:51 +00:00
|
|
|
# QUIC "is currently supported as an experimental feature" so shouldn't be enabled by default
|
|
|
|
, useQuicTls ? false
|
2020-04-24 23:36:52 +00:00
|
|
|
, withPrometheusExporter ? true
|
2023-08-04 22:07:22 +00:00
|
|
|
, stdenv
|
|
|
|
, lib
|
|
|
|
, fetchurl
|
|
|
|
, nixosTests
|
|
|
|
, zlib
|
|
|
|
, libxcrypt
|
2024-01-13 08:15:51 +00:00
|
|
|
, openssl ? null
|
|
|
|
, quictls ? null
|
2023-08-04 22:07:22 +00:00
|
|
|
, lua5_3 ? null
|
|
|
|
, pcre ? null
|
|
|
|
, systemd ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert useLua -> lua5_3 != null;
|
|
|
|
assert usePcre -> pcre != null;
|
2024-01-13 08:15:51 +00:00
|
|
|
assert useQuicTls -> quictls != null;
|
|
|
|
assert !useQuicTls -> openssl != null;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
let sslPkg = if useQuicTls then quictls else openssl;
|
|
|
|
in stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "haproxy";
|
2024-01-13 08:15:51 +00:00
|
|
|
version = "2.9.1";
|
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-01-13 08:15:51 +00:00
|
|
|
hash = "sha256-1YAcdyqrnEP0CWS3sztDiNFLW0V1C+TSZxeFhjzbnxw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
buildInputs = [ sslPkg zlib libxcrypt ]
|
2020-04-24 23:36:52 +00:00
|
|
|
++ lib.optional useLua lua5_3
|
|
|
|
++ lib.optional usePcre pcre
|
|
|
|
++ 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_OPENSSL=yes"
|
2024-01-13 08:15:51 +00:00
|
|
|
"SSL_LIB=${sslPkg}/lib"
|
|
|
|
"SSL_INC=${sslPkg}/include"
|
2020-04-24 23:36:52 +00:00
|
|
|
"USE_ZLIB=yes"
|
2024-01-13 08:15:51 +00:00
|
|
|
] ++ lib.optionals useQuicTls [
|
|
|
|
"USE_QUIC=1"
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ lib.optionals usePcre [
|
|
|
|
"USE_PCRE=yes"
|
|
|
|
"USE_PCRE_JIT=yes"
|
|
|
|
] ++ lib.optionals useLua [
|
|
|
|
"USE_LUA=yes"
|
2021-05-20 23:08:51 +00:00
|
|
|
"LUA_LIB_NAME=lua"
|
2020-04-24 23:36:52 +00:00
|
|
|
"LUA_LIB=${lua5_3}/lib"
|
|
|
|
"LUA_INC=${lua5_3}/include"
|
|
|
|
] ++ 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.
|
|
|
|
'';
|
2023-08-04 22:07:22 +00:00
|
|
|
maintainers = with lib.maintainers; [ ];
|
|
|
|
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
|
|
|
})
|