2015-03-18 20:33:52 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.fluentd;
|
2017-08-09 00:02:56 +02:00
|
|
|
|
|
|
|
pluginArgs = concatStringsSep " " (map (x: "-p ${x}") cfg.plugins);
|
2015-03-18 20:33:52 +01:00
|
|
|
in {
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fluentd = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Whether to enable fluentd.";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = "Fluentd config.";
|
|
|
|
};
|
2017-01-27 16:08:17 +01:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = pkgs.fluentd;
|
2017-03-07 14:01:50 +01:00
|
|
|
defaultText = "pkgs.fluentd";
|
2017-01-27 16:08:17 +01:00
|
|
|
description = "The fluentd package to use.";
|
|
|
|
};
|
2017-08-09 00:02:56 +02:00
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
A list of plugin paths to pass into fluentd. It will make plugins defined in ruby files
|
|
|
|
there available in your config.
|
|
|
|
'';
|
|
|
|
};
|
2015-03-18 20:33:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.fluentd = with pkgs; {
|
|
|
|
description = "Fluentd Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2017-08-09 00:02:56 +02:00
|
|
|
ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config} ${pluginArgs}";
|
2015-04-25 14:21:27 +02:00
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
2015-03-18 20:33:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|