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