depot/third_party/nixpkgs/nixos/modules/services/logging/fluentd.nix
Default email 01ed8ef136 Project import generated by Copybara.
GitOrigin-RevId: 20fc948445a6c22d4e8d5178e9a6bc6e1f5417c8
2022-11-21 19:40:18 +02:00

54 lines
1.3 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.fluentd;
pluginArgs = concatStringsSep " " (map (x: "-p ${x}") cfg.plugins);
in {
###### interface
options = {
services.fluentd = {
enable = mkEnableOption (lib.mdDoc "fluentd");
config = mkOption {
type = types.lines;
default = "";
description = lib.mdDoc "Fluentd config.";
};
package = mkOption {
type = types.path;
default = pkgs.fluentd;
defaultText = literalExpression "pkgs.fluentd";
description = lib.mdDoc "The fluentd package to use.";
};
plugins = mkOption {
type = types.listOf types.path;
default = [];
description = lib.mdDoc ''
A list of plugin paths to pass into fluentd. It will make plugins defined in ruby files
there available in your config.
'';
};
};
};
###### implementation
config = mkIf cfg.enable {
systemd.services.fluentd = with pkgs; {
description = "Fluentd Daemon";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config} ${pluginArgs}";
ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
};
};
};
}