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 = mkOption {
16 type = types.bool;
17 default = false;
18 description = "Whether to enable fluentd.";
19 };
20
21 config = mkOption {
22 type = types.lines;
23 default = "";
24 description = "Fluentd config.";
25 };
26
27 package = mkOption {
28 type = types.path;
29 default = pkgs.fluentd;
30 defaultText = "pkgs.fluentd";
31 description = "The fluentd package to use.";
32 };
33
34 plugins = mkOption {
35 type = types.listOf types.path;
36 default = [];
37 description = ''
38 A list of plugin paths to pass into fluentd. It will make plugins defined in ruby files
39 there available in your config.
40 '';
41 };
42 };
43 };
44
45
46 ###### implementation
47
48 config = mkIf cfg.enable {
49 systemd.services.fluentd = with pkgs; {
50 description = "Fluentd Daemon";
51 wantedBy = [ "multi-user.target" ];
52 serviceConfig = {
53 ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config} ${pluginArgs}";
54 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
55 };
56 };
57 };
58}