at 23.11-pre 1.6 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let cfg = config.services.SystemdJournal2Gelf; 6in 7 8{ options = { 9 services.SystemdJournal2Gelf = { 10 enable = mkOption { 11 type = types.bool; 12 default = false; 13 description = lib.mdDoc '' 14 Whether to enable SystemdJournal2Gelf. 15 ''; 16 }; 17 18 graylogServer = mkOption { 19 type = types.str; 20 example = "graylog2.example.com:11201"; 21 description = lib.mdDoc '' 22 Host and port of your graylog2 input. This should be a GELF 23 UDP input. 24 ''; 25 }; 26 27 extraOptions = mkOption { 28 type = types.separatedString " "; 29 default = ""; 30 description = lib.mdDoc '' 31 Any extra flags to pass to SystemdJournal2Gelf. Note that 32 these are basically `journalctl` flags. 33 ''; 34 }; 35 36 package = mkOption { 37 type = types.package; 38 default = pkgs.systemd-journal2gelf; 39 defaultText = literalExpression "pkgs.systemd-journal2gelf"; 40 description = lib.mdDoc '' 41 SystemdJournal2Gelf package to use. 42 ''; 43 }; 44 45 }; 46 }; 47 48 config = mkIf cfg.enable { 49 systemd.services.SystemdJournal2Gelf = { 50 description = "SystemdJournal2Gelf"; 51 after = [ "network.target" ]; 52 wantedBy = [ "multi-user.target" ]; 53 serviceConfig = { 54 ExecStart = "${cfg.package}/bin/SystemdJournal2Gelf ${cfg.graylogServer} --follow ${cfg.extraOptions}"; 55 Restart = "on-failure"; 56 RestartSec = "30"; 57 }; 58 }; 59 }; 60}