1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.fluentd;
7in {
8 ###### interface
9
10 options = {
11
12 services.fluentd = {
13 enable = mkOption {
14 type = types.bool;
15 default = false;
16 description = "Whether to enable fluentd.";
17 };
18
19 config = mkOption {
20 type = types.lines;
21 default = "";
22 description = "Fluentd config.";
23 };
24 };
25 };
26
27
28 ###### implementation
29
30 config = mkIf cfg.enable {
31 systemd.services.fluentd = with pkgs; {
32 description = "Fluentd Daemon";
33 wantedBy = [ "multi-user.target" ];
34 serviceConfig = {
35 ExecStart = "${pkgs.fluentd}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config}";
36 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
37 };
38 };
39 };
40}