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 = ''
14 Whether to enable SystemdJournal2Gelf.
15 '';
16 };
17
18 graylogServer = mkOption {
19 type = types.string;
20 example = "graylog2.example.com:11201";
21 description = ''
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.string;
29 default = "";
30 description = ''
31 Any extra flags to pass to SystemdJournal2Gelf. Note that
32 these are basically <literal>journalctl</literal> flags.
33 '';
34 };
35
36 package = mkOption {
37 type = types.package;
38 default = pkgs.systemd-journal2gelf;
39 description = ''
40 SystemdJournal2Gelf package to use.
41 '';
42 };
43
44 };
45 };
46
47 config = mkIf cfg.enable {
48 systemd.services.SystemdJournal2Gelf = {
49 description = "SystemdJournal2Gelf";
50 after = [ "network.target" ];
51 wantedBy = [ "multi-user.target" ];
52 serviceConfig = {
53 ExecStart = "${cfg.package}/bin/SystemdJournal2Gelf ${cfg.graylogServer} --follow ${cfg.extraOptions}";
54 Restart = "on-failure";
55 RestartSec = "30";
56 };
57 };
58 };
59}