2015-03-18 19:33:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.fluentd;
|
2017-08-08 23:02:56 +01:00
|
|
|
|
|
|
|
pluginArgs = concatStringsSep " " (map (x: "-p ${x}") cfg.plugins);
|
2015-03-18 19:33:52 +00:00
|
|
|
in {
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fluentd = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Whether to enable fluentd.";
|
2015-03-18 19:33:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "Fluentd config.";
|
2015-03-18 19:33:52 +00:00
|
|
|
};
|
2017-01-27 15:08:17 +00:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = pkgs.fluentd;
|
2021-10-03 17:06:03 +01:00
|
|
|
defaultText = literalExpression "pkgs.fluentd";
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc "The fluentd package to use.";
|
2017-01-27 15:08:17 +00:00
|
|
|
};
|
2017-08-08 23:02:56 +01:00
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
default = [];
|
2022-07-28 22:19:15 +01:00
|
|
|
description = lib.mdDoc ''
|
2017-08-08 23:02:56 +01:00
|
|
|
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 19:33:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.fluentd = with pkgs; {
|
|
|
|
description = "Fluentd Daemon";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
2017-08-08 23:02:56 +01:00
|
|
|
ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config} ${pluginArgs}";
|
2015-04-25 13:21:27 +01:00
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
|
2015-03-18 19:33:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|