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