nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, fetchFromGitHub, cmake, flex, bison, systemd, postgresql, openssl, libyaml }:
2
3stdenv.mkDerivation rec {
4 pname = "fluent-bit";
5 version = "2.1.4";
6
7 src = fetchFromGitHub {
8 owner = "fluent";
9 repo = "fluent-bit";
10 rev = "v${version}";
11 sha256 = "sha256-WaIGTQiBVbLpSw17rBd1KbllkGEnSSXAPdO0CcbSNSI=";
12 };
13
14 nativeBuildInputs = [ cmake flex bison ];
15
16 buildInputs = [ openssl libyaml postgresql ]
17 ++ lib.optionals stdenv.isLinux [ systemd ];
18
19 cmakeFlags = [ "-DFLB_METRICS=ON" "-DFLB_HTTP_SERVER=ON" "-DFLB_OUT_PGSQL=ON" ];
20
21 # _FORTIFY_SOURCE requires compiling with optimization (-O)
22 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.cc.isGNU [ "-O" ]
23 # Workaround build failure on -fno-common toolchains:
24 # ld: /monkey/mk_tls.h:81: multiple definition of `mk_tls_server_timeout';
25 # flb_config.c.o:include/monkey/mk_tls.h:81: first defined here
26 # TODO: drop when upstream gets a fix for it:
27 # https://github.com/fluent/fluent-bit/issues/5537
28 ++ lib.optionals stdenv.isDarwin [ "-fcommon" ]);
29
30 outputs = [ "out" "dev" ];
31
32 postPatch = ''
33 substituteInPlace src/CMakeLists.txt \
34 --replace /lib/systemd $out/lib/systemd
35 '';
36
37 meta = with lib; {
38 description = "Log forwarder and processor, part of Fluentd ecosystem";
39 homepage = "https://fluentbit.io";
40 maintainers = with maintainers; [ samrose fpletz ];
41 license = licenses.asl20;
42 platforms = platforms.linux;
43 };
44}