1{ config, lib, pkgs, ... }:
2
3let
4 inherit (lib) mkEnableOption mkIf mkOption types;
5 inherit (pkgs) solanum;
6 cfg = config.services.solanum;
7
8 configFile = pkgs.writeText "solanum.conf" cfg.config;
9in
10
11{
12
13 ###### interface
14
15 options = {
16
17 services.solanum = {
18
19 enable = mkEnableOption "Solanum IRC daemon";
20
21 config = mkOption {
22 type = types.str;
23 default = ''
24 serverinfo {
25 name = "irc.example.com";
26 sid = "1ix";
27 description = "irc!";
28
29 vhost = "0.0.0.0";
30 vhost6 = "::";
31 };
32
33 listen {
34 host = "0.0.0.0";
35 port = 6667;
36 };
37
38 auth {
39 user = "*@*";
40 class = "users";
41 flags = exceed_limit;
42 };
43 channel {
44 default_split_user_count = 0;
45 };
46 '';
47 description = ''
48 Solanum IRC daemon configuration file.
49 check <link xlink:href="https://github.com/solanum-ircd/solanum/blob/main/doc/reference.conf"/> for all options.
50 '';
51 };
52
53 openFilesLimit = mkOption {
54 type = types.int;
55 default = 1024;
56 description = ''
57 Maximum number of open files. Limits the clients and server connections.
58 '';
59 };
60
61 motd = mkOption {
62 type = types.nullOr types.lines;
63 default = null;
64 description = ''
65 Solanum MOTD text.
66
67 Solanum will read its MOTD from <literal>/etc/solanum/ircd.motd</literal>.
68 If set, the value of this option will be written to this path.
69 '';
70 };
71
72 };
73
74 };
75
76
77 ###### implementation
78
79 config = mkIf cfg.enable (lib.mkMerge [
80 {
81 systemd.services.solanum = {
82 description = "Solanum IRC daemon";
83 after = [ "network.target" ];
84 wantedBy = [ "multi-user.target" ];
85 environment = {
86 BANDB_DBPATH = "/var/lib/solanum/ban.db";
87 };
88 serviceConfig = {
89 ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile ${configFile} -pidfile /run/solanum/ircd.pid";
90 DynamicUser = true;
91 User = "solanum";
92 StateDirectory = "solanum";
93 RuntimeDirectory = "solanum";
94 LimitNOFILE = "${toString cfg.openFilesLimit}";
95 };
96 };
97
98 }
99
100 (mkIf (cfg.motd != null) {
101 environment.etc."solanum/ircd.motd".text = cfg.motd;
102 })
103 ]);
104}