2021-05-28 09:39:13 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mkEnableOption mkIf mkOption types;
|
2021-06-28 23:13:55 +00:00
|
|
|
inherit (pkgs) solanum util-linux;
|
2021-05-28 09:39:13 +00:00
|
|
|
cfg = config.services.solanum;
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "solanum.conf" cfg.config;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.solanum = {
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
enable = mkEnableOption (lib.mdDoc "Solanum IRC daemon");
|
2021-05-28 09:39:13 +00:00
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = ''
|
|
|
|
serverinfo {
|
|
|
|
name = "irc.example.com";
|
|
|
|
sid = "1ix";
|
|
|
|
description = "irc!";
|
|
|
|
|
|
|
|
vhost = "0.0.0.0";
|
|
|
|
vhost6 = "::";
|
|
|
|
};
|
|
|
|
|
|
|
|
listen {
|
|
|
|
host = "0.0.0.0";
|
|
|
|
port = 6667;
|
|
|
|
};
|
|
|
|
|
|
|
|
auth {
|
|
|
|
user = "*@*";
|
|
|
|
class = "users";
|
|
|
|
flags = exceed_limit;
|
|
|
|
};
|
|
|
|
channel {
|
|
|
|
default_split_user_count = 0;
|
|
|
|
};
|
|
|
|
'';
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-05-28 09:39:13 +00:00
|
|
|
Solanum IRC daemon configuration file.
|
2022-08-12 12:06:08 +00:00
|
|
|
check <https://github.com/solanum-ircd/solanum/blob/main/doc/reference.conf> for all options.
|
2021-05-28 09:39:13 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
openFilesLimit = mkOption {
|
|
|
|
type = types.int;
|
|
|
|
default = 1024;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-05-28 09:39:13 +00:00
|
|
|
Maximum number of open files. Limits the clients and server connections.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
motd = mkOption {
|
|
|
|
type = types.nullOr types.lines;
|
|
|
|
default = null;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2021-05-28 09:39:13 +00:00
|
|
|
Solanum MOTD text.
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
Solanum will read its MOTD from `/etc/solanum/ircd.motd`.
|
2021-05-28 09:39:13 +00:00
|
|
|
If set, the value of this option will be written to this path.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable (lib.mkMerge [
|
|
|
|
{
|
2021-06-28 23:13:55 +00:00
|
|
|
|
|
|
|
environment.etc."solanum/ircd.conf".source = configFile;
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
systemd.services.solanum = {
|
|
|
|
description = "Solanum IRC daemon";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2021-06-28 23:13:55 +00:00
|
|
|
reloadIfChanged = true;
|
|
|
|
restartTriggers = [
|
|
|
|
configFile
|
|
|
|
];
|
2021-05-28 09:39:13 +00:00
|
|
|
serviceConfig = {
|
2021-06-28 23:13:55 +00:00
|
|
|
ExecStart = "${solanum}/bin/solanum -foreground -logfile /dev/stdout -configfile /etc/solanum/ircd.conf -pidfile /run/solanum/ircd.pid";
|
|
|
|
ExecReload = "${util-linux}/bin/kill -HUP $MAINPID";
|
2021-05-28 09:39:13 +00:00
|
|
|
DynamicUser = true;
|
|
|
|
User = "solanum";
|
|
|
|
StateDirectory = "solanum";
|
|
|
|
RuntimeDirectory = "solanum";
|
|
|
|
LimitNOFILE = "${toString cfg.openFilesLimit}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(mkIf (cfg.motd != null) {
|
|
|
|
environment.etc."solanum/ircd.motd".text = cfg.motd;
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|