1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.irkerd;
7 ports = [ 6659 ];
8in
9{
10 options.services.irkerd = {
11 enable = mkOption {
12 description = "Whether to enable irker, an IRC notification daemon.";
13 default = false;
14 type = types.bool;
15 };
16
17 openPorts = mkOption {
18 description = "Open ports in the firewall for irkerd";
19 default = false;
20 type = types.bool;
21 };
22
23 listenAddress = mkOption {
24 default = "localhost";
25 example = "0.0.0.0";
26 type = types.str;
27 description = ''
28 Specifies the bind address on which the irker daemon listens.
29 The default is localhost.
30
31 Irker authors strongly warn about the risks of running this on
32 a publicly accessible interface, so change this with caution.
33 '';
34 };
35
36 nick = mkOption {
37 default = "irker";
38 type = types.str;
39 description = "Nick to use for irker";
40 };
41 };
42
43 config = mkIf cfg.enable {
44 systemd.services.irkerd = {
45 description = "Internet Relay Chat (IRC) notification daemon";
46 documentation = [ "man:irkerd(8)" "man:irkerhook(1)" "man:irk(1)" ];
47 after = [ "network.target" ];
48 wantedBy = [ "multi-user.target" ];
49 serviceConfig = {
50 ExecStart = "${pkgs.irker}/bin/irkerd -H ${cfg.listenAddress} -n ${cfg.nick}";
51 User = "irkerd";
52 };
53 };
54
55 environment.systemPackages = [ pkgs.irker ];
56
57 users.users.irkerd = {
58 description = "Irker daemon user";
59 isSystemUser = true;
60 group = "irkerd";
61 };
62 users.groups.irkerd = {};
63
64 networking.firewall.allowedTCPPorts = mkIf cfg.openPorts ports;
65 networking.firewall.allowedUDPPorts = mkIf cfg.openPorts ports;
66 };
67}