-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathirccat.nix
80 lines (77 loc) · 2.38 KB
/
irccat.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# TODO: upstream this
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.irccat;
format = pkgs.formats.json { };
cfgFile = format.generate "config.json" cfg.config;
in {
options = {
services.irccat = {
enable = mkEnableOption (lib.mdDoc "Irccat irc event sender");
package = mkPackageOption pkgs "irccat" { };
config = mkOption {
type = types.submodule {
freeformType = format.type;
options.irc.server = mkOption {
type = types.str;
description = lib.mdDoc ''
The host:port of the IRC server to connect to
'';
example = "irc.libera.chat:6697";
};
options.irc.tls = mkOption {
type = types.bool;
default = true;
description = lib.mdDoc ''
Whether to secure the IRC connection with TLS
'';
};
options.irc.nick = mkOption {
type = types.str;
description = lib.mdDoc ''
The nick irccat will use
'';
};
options.http.listen = mkOption {
type = types.str;
description = mdDoc ''
The listen address:port to listen on for HTTP
'';
};
};
description = ''
irccat configuration. For supported values, see the
[example json](https://github.com/irccloud/irccat/blob/master/examples/irccat.json).
'';
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.irccat = {
description = "Irccat IRC event sender";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/irccat -config ${cfgFile}";
DynamicUser = true;
# Basic hardening
NoNewPrivileges = "yes";
PrivateTmp = "yes";
PrivateDevices = "yes";
DevicePolicy = "closed";
ProtectSystem = "strict";
ProtectHome = "read-only";
ProtectControlGroups = "yes";
ProtectKernelModules = "yes";
ProtectKernelTunables = "yes";
RestrictAddressFamilies = "AF_UNIX AF_INET AF_INET6 AF_NETLINK";
RestrictNamespaces = "yes";
RestrictRealtime = "yes";
RestrictSUIDSGID = "yes";
MemoryDenyWriteExecute = "yes";
LockPersonality = "yes";
};
};
};
}