9 cfg = config.services.journald.gateway;
11 cliArgs = lib.cli.toGNUCommandLineShell { } {
12 # If either of these are null / false, they are not passed in the command-line
24 meta.maintainers = [ lib.maintainers.raitobezarius ];
25 options.services.journald.gateway = {
26 enable = lib.mkEnableOption "the HTTP gateway to the journal";
30 type = lib.types.port;
32 The port to listen to.
38 type = with lib.types; nullOr str;
40 The path to a file or `AF_UNIX` stream socket to read the server
43 The certificate must be in PEM format. This option switches
44 `systemd-journal-gatewayd` into HTTPS mode and must be used together
45 with {option}`services.journald.gateway.key`.
51 type = with lib.types; nullOr str;
53 Specify the path to a file or `AF_UNIX` stream socket to read the
54 secret server key corresponding to the certificate specified with
55 {option}`services.journald.gateway.cert` from.
57 The key must be in PEM format.
59 This key should not be world-readable, and must be readably by the
60 `systemd-journal-gateway` user.
64 trust = lib.mkOption {
66 type = with lib.types; nullOr str;
68 Specify the path to a file or `AF_UNIX` stream socket to read a CA
71 The certificate must be in PEM format.
73 Setting this option enforces client certificate checking.
77 system = lib.mkOption {
79 type = lib.types.bool;
81 Serve entries from system services and the kernel.
83 This has the same meaning as `--system` for {manpage}`journalctl(1)`.
89 type = lib.types.bool;
91 Serve entries from services for the current user.
93 This has the same meaning as `--user` for {manpage}`journalctl(1)`.
97 merge = lib.mkOption {
99 type = lib.types.bool;
101 Serve entries interleaved from all available journals, including other
104 This has the same meaning as `--merge` option for
105 {manpage}`journalctl(1)`.
110 config = lib.mkIf cfg.enable {
113 # This prevents the weird case were disabling "system" and "user"
114 # actually enables both because the cli flags are not present.
115 assertion = cfg.system || cfg.user;
117 systemd-journal-gatewayd cannot serve neither "system" nor "user"
123 systemd.additionalUpstreamSystemUnits = [
124 "systemd-journal-gatewayd.socket"
125 "systemd-journal-gatewayd.service"
128 users.users.systemd-journal-gateway.uid = config.ids.uids.systemd-journal-gateway;
129 users.users.systemd-journal-gateway.group = "systemd-journal-gateway";
130 users.groups.systemd-journal-gateway.gid = config.ids.gids.systemd-journal-gateway;
132 systemd.services.systemd-journal-gatewayd.serviceConfig.ExecStart = [
133 # Clear the default command line
135 "${pkgs.systemd}/lib/systemd/systemd-journal-gatewayd ${cliArgs}"
138 systemd.sockets.systemd-journal-gatewayd = {
139 wantedBy = [ "sockets.target" ];
141 # Clear the default port