stockholm/krebs/3modules/ergo.nix

102 lines
2.2 KiB
Nix
Raw Normal View History

2021-12-28 21:33:36 +00:00
{ config, lib, options, pkgs, ... }:
2021-06-08 15:41:21 +00:00
let
inherit (lib) mkEnableOption mkIf mkOption types;
inherit (pkgs) coreutils ergo;
cfg = config.krebs.ergo;
configFile = pkgs.writeText "ergo.conf" (builtins.toJSON cfg.config);
in
{
###### interface
options = {
krebs.ergo = {
enable = mkEnableOption "Ergo IRC daemon";
config = mkOption {
type = (pkgs.formats.json {}).type;
description = ''
Ergo IRC daemon configuration file.
'';
default = {
network = {
name = "krebstest";
};
server = {
name = "${config.networking.hostName}.r";
listeners = {
":6667" = {};
};
casemapping = "permissive";
enforce-utf = true;
lookup-hostnames = false;
ip-cloaking = {
enabled = false;
};
forward-confirm-hostnames = false;
check-ident = false;
relaymsg = {
enabled = false;
};
max-sendq = "1M";
ip-limits = {
count = false;
throttle = false;
};
};
datastore = {
2021-12-28 21:20:54 +00:00
path = "/var/lib/ergo/ircd.db";
2021-06-08 15:41:21 +00:00
};
accounts = {
authentication-enabled = true;
registration = {
enabled = true;
email-verification = {
enabled = false;
};
};
};
channels = {
default-modes = "+nt";
};
limits = {
nicklen = 32;
identlen = 20;
channellen = 64;
awaylen = 390;
kicklen = 390;
topiclen = 390;
};
};
};
};
};
###### implementation
config = mkIf cfg.enable ({
2021-12-28 21:33:36 +00:00
krebs.ergo.config =
lib.mapAttrsRecursive (_: lib.mkDefault) options.krebs.ergo.config.default;
2021-06-08 15:41:21 +00:00
systemd.services.ergo = {
description = "Ergo IRC daemon";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${ergo}/bin/ergo run --conf ${configFile}";
2021-12-28 21:20:54 +00:00
DynamicUser = true;
StateDirectory = "ergo";
2021-06-08 15:41:21 +00:00
};
};
});
}