diff options
Diffstat (limited to 'nixpkgs/nixos/modules/services/logging/fluentd.nix')
-rw-r--r-- | nixpkgs/nixos/modules/services/logging/fluentd.nix | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/logging/fluentd.nix b/nixpkgs/nixos/modules/services/logging/fluentd.nix new file mode 100644 index 000000000000..95825705d9d7 --- /dev/null +++ b/nixpkgs/nixos/modules/services/logging/fluentd.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.fluentd; + + pluginArgs = concatStringsSep " " (map (x: "-p ${x}") cfg.plugins); +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."; + }; + + package = mkOption { + type = types.path; + default = pkgs.fluentd; + defaultText = "pkgs.fluentd"; + description = "The fluentd package to use."; + }; + + 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. + ''; + }; + }; + }; + + + ###### 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"; + }; + }; + }; +} |