1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.fluentd;
7
8 pluginArgs = concatStringsSep " " (map (x: "-p ${x}") cfg.plugins);
9in {
10 ###### interface
11
12 options = {
13
14 services.fluentd = {
15 enable = mkEnableOption "fluentd, a data/log collector";
16
17 config = mkOption {
18 type = types.lines;
19 default = "";
20 description = "Fluentd config.";
21 };
22
23 package = mkPackageOption pkgs "fluentd" { };
24
25 plugins = mkOption {
26 type = types.listOf types.path;
27 default = [];
28 description = ''
29 A list of plugin paths to pass into fluentd. It will make plugins defined in ruby files
30 there available in your config.
31 '';
32 };
33 };
34 };
35
36
37 ###### implementation
38
39 config = mkIf cfg.enable {
40 systemd.services.fluentd = with pkgs; {
41 description = "Fluentd Daemon";
42 wantedBy = [ "multi-user.target" ];
43 serviceConfig = {
44 ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config} ${pluginArgs}";
45 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
46 };
47 };
48 };
49}