nixpkgs/pkgs/tools/networking/haproxy/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

100 lines
2.8 KiB
Nix
Raw Normal View History

2023-05-24 23:27:07 +01:00
{ useLua ? true
, usePcre ? true
2019-11-08 04:25:03 +00:00
, withPrometheusExporter ? true
, sslLibrary ? "quictls"
2023-08-01 22:07:07 +01:00
, stdenv
, lib
, fetchurl
, nixosTests
, zlib
, libxcrypt
, wolfssl
, libressl
, quictls
, openssl
, lua5_4
, pcre2
, systemd
}:
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};
in stdenv.mkDerivation (finalAttrs: {
2017-01-26 08:37:51 +00:00
pname = "haproxy";
2024-02-27 17:36:36 +00:00
version = "2.9.6";
2013-10-29 14:55:25 +00:00
src = fetchurl {
2023-08-01 22:07:07 +01:00
url = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/haproxy-${finalAttrs.version}.tar.gz";
2024-02-27 17:36:36 +00:00
hash = "sha256-IIrfR8j6g8VJeANLpcARC3RjxHB48Rm9BSNCFxo7mgs=";
};
buildInputs = [ sslPkg zlib libxcrypt ]
++ lib.optional useLua lua5_4
++ lib.optional usePcre pcre2
2019-11-08 04:25:03 +00:00
++ lib.optional stdenv.isLinux systemd;
2017-03-07 17:50:45 +00:00
# TODO: make it work on bsd as well
makeFlags = [
"PREFIX=${placeholder "out"}"
2023-08-01 22:07:07 +01:00
("TARGET=" + (if stdenv.isSunOS then "solaris"
else if stdenv.isLinux then "linux-glibc"
else if stdenv.isDarwin then "osx"
else "generic"))
];
2019-11-08 04:25:03 +00:00
buildFlags = [
"USE_ZLIB=yes"
"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"
2019-11-08 04:25:03 +00:00
] ++ lib.optionals usePcre [
"USE_PCRE2=yes"
"USE_PCRE2_JIT=yes"
2019-11-08 04:25:03 +00:00
] ++ lib.optionals useLua [
"USE_LUA=yes"
2021-05-07 22:07:59 +01:00
"LUA_LIB_NAME=lua"
"LUA_LIB=${lua5_4}/lib"
"LUA_INC=${lua5_4}/include"
2019-11-08 04:25:03 +00:00
] ++ lib.optionals stdenv.isLinux [
"USE_SYSTEMD=yes"
"USE_GETADDRINFO=1"
] ++ lib.optionals withPrometheusExporter [
"USE_PROMEX=yes"
] ++ [ "CC=${stdenv.cc.targetPrefix}cc" ];
2019-11-08 04:25:03 +00:00
enableParallelBuilding = true;
2020-11-14 04:20:00 +00:00
passthru.tests.haproxy = nixosTests.haproxy;
2023-08-01 22:07:07 +01:00
meta = {
changelog = "https://www.haproxy.org/download/${lib.versions.majorMinor finalAttrs.version}/src/CHANGELOG";
description = "Reliable, high performance TCP/HTTP load balancer";
2023-08-01 22:07:07 +01:00
homepage = "https://haproxy.org";
license = with lib.licenses; [ gpl2Plus lgpl21Only ];
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.
'';
maintainers = with lib.maintainers; [ vifino ];
2023-08-01 22:07:07 +01:00
platforms = with lib.platforms; linux ++ darwin;
mainProgram = "haproxy";
};
2023-08-01 22:07:07 +01:00
})