at 23.11-pre 1.3 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 cfg = config.services.fluentd; 7 8 pluginArgs = concatStringsSep " " (map (x: "-p ${x}") cfg.plugins); 9in { 10 ###### interface 11 12 options = { 13 14 services.fluentd = { 15 enable = mkEnableOption (lib.mdDoc "fluentd"); 16 17 config = mkOption { 18 type = types.lines; 19 default = ""; 20 description = lib.mdDoc "Fluentd config."; 21 }; 22 23 package = mkOption { 24 type = types.path; 25 default = pkgs.fluentd; 26 defaultText = literalExpression "pkgs.fluentd"; 27 description = lib.mdDoc "The fluentd package to use."; 28 }; 29 30 plugins = mkOption { 31 type = types.listOf types.path; 32 default = []; 33 description = lib.mdDoc '' 34 A list of plugin paths to pass into fluentd. It will make plugins defined in ruby files 35 there available in your config. 36 ''; 37 }; 38 }; 39 }; 40 41 42 ###### implementation 43 44 config = mkIf cfg.enable { 45 systemd.services.fluentd = with pkgs; { 46 description = "Fluentd Daemon"; 47 wantedBy = [ "multi-user.target" ]; 48 serviceConfig = { 49 ExecStart = "${cfg.package}/bin/fluentd -c ${pkgs.writeText "fluentd.conf" cfg.config} ${pluginArgs}"; 50 ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 51 }; 52 }; 53 }; 54}