stockholm/krebs/3modules/ergo.nix

134 lines
3.9 KiB
Nix
Raw Normal View History

2021-12-28 22:53:27 +00:00
{ config, lib, options, pkgs, ... }: {
2021-06-08 15:41:21 +00:00
options = {
krebs.ergo = {
2021-12-28 22:53:27 +00:00
enable = lib.mkEnableOption "Ergo IRC daemon";
openFilesLimit = lib.mkOption {
type = lib.types.int;
default = 1024;
description = ''
Maximum number of open files. Limits the clients and server connections.
'';
};
2021-12-28 22:53:27 +00:00
config = lib.mkOption {
2021-06-08 15:41:21 +00:00
type = (pkgs.formats.json {}).type;
description = ''
Ergo IRC daemon configuration file.
2021-12-29 14:52:29 +00:00
https://raw.githubusercontent.com/ergochat/ergo/master/default.yaml
2021-06-08 15:41:21 +00:00
'';
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-29 14:52:29 +00:00
autoupgrade = true;
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;
2021-12-29 14:52:29 +00:00
allow-before-connect = true;
throttling = {
enabled = true;
duration = "10m";
max-attempts = 30;
};
bcrypt-cost = 4;
email-verification.enabled = false;
2021-12-29 15:23:59 +00:00
};
multiclient = {
enabled = true;
allowed-by-default = true;
always-on = "opt-out";
auto-away = "opt-out";
2021-06-08 15:41:21 +00:00
};
};
channels = {
2021-12-29 14:52:29 +00:00
default-modes = "+ntC";
registration = {
enabled = true;
};
2021-06-08 15:41:21 +00:00
};
limits = {
nicklen = 32;
identlen = 20;
channellen = 64;
awaylen = 390;
kicklen = 390;
topiclen = 390;
};
2021-12-29 14:52:29 +00:00
history = {
enabled = true;
channel-length = 2048;
client-length = 256;
autoresize-window = "3d";
autoreplay-on-join = 0;
chathistory-maxmessages = 100;
znc-maxmessages = 2048;
restrictions = {
expire-time = "1w";
query-cutoff = "none";
grace-period = "1h";
};
retention = {
allow-individual-delete = false;
enable-account-indexing = false;
};
tagmsg-storage = {
default = false;
whitelist = [
"+draft/react"
"+react"
];
};
};
2021-06-08 15:41:21 +00:00
};
};
};
};
2021-12-28 22:53:27 +00:00
config = let
cfg = config.krebs.ergo;
configFile = pkgs.writeJSON "ergo.conf" cfg.config;
in lib.mkIf cfg.enable ({
2021-12-29 14:52:29 +00:00
environment.etc."ergo.yaml".source = configFile;
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" ];
# reload currently not working as expected
# reloadIfChanged = true;
2021-12-29 14:52:29 +00:00
restartTriggers = [ configFile ];
2021-06-08 15:41:21 +00:00
serviceConfig = {
2022-11-21 14:04:30 +00:00
ExecStart = "${pkgs.ergochat}/bin/ergo run --conf /etc/ergo.yaml";
2021-12-29 14:52:29 +00:00
ExecReload = "${pkgs.util-linux}/bin/kill -HUP $MAINPID";
2021-12-28 21:20:54 +00:00
DynamicUser = true;
StateDirectory = "ergo";
LimitNOFILE = "${toString cfg.openFilesLimit}";
2021-06-08 15:41:21 +00:00
};
};
});
}