depot/nixos/modules/services/logging/fluentd.nix
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

46 lines
1.1 KiB
Nix

{ config, lib, pkgs, ... }:
let
cfg = config.services.fluentd;
pluginArgs = lib.concatStringsSep " " (map (x: "-p ${x}") cfg.plugins);
in {
###### interface
options = {
services.fluentd = {
enable = lib.mkEnableOption "fluentd, a data/log collector";
config = lib.mkOption {
type = lib.types.lines;
default = "";
description = "Fluentd config.";
};
package = lib.mkPackageOption pkgs "fluentd" { };
plugins = lib.mkOption {
type = lib.types.listOf lib.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 = lib.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";
};
};
};
}