stockholm/tv/3modules/charybdis/default.nix

81 lines
2.1 KiB
Nix
Raw Normal View History

2016-10-20 18:54:38 +00:00
{ config, lib, pkgs, ... }@args: with import <stockholm/lib>; let
2016-02-21 05:23:06 +00:00
cfg = config.tv.charybdis;
in {
options.tv.charybdis = {
enable = mkEnableOption "tv.charybdis";
motd = mkOption {
type = types.str;
default = "/join #retiolum";
};
port = mkOption {
type = types.int;
default = 6667;
};
ssl_cert = mkOption {
type = types.path;
};
ssl_dh_params = mkOption {
2021-12-25 10:41:15 +00:00
type = types.absolute-pathname;
default = toString <secrets> + "/charybdis.dh.pem";
2016-02-21 05:23:06 +00:00
};
ssl_private_key = mkOption {
2021-12-25 10:41:15 +00:00
type = types.absolute-pathname;
default = toString <secrets> + "/charybdis.key.pem";
2016-02-21 05:23:06 +00:00
};
sslport = mkOption {
type = types.int;
default = 6697;
};
user = mkOption {
2016-02-21 05:39:12 +00:00
type = types.user;
2016-02-21 05:23:06 +00:00
default = {
name = "charybdis";
home = "/var/lib/charybdis";
};
};
};
config = lib.mkIf cfg.enable {
environment.etc."charybdis-ircd.motd".text = cfg.motd;
2021-12-25 10:41:15 +00:00
krebs.systemd.services.charybdis = {};
2016-02-21 05:23:06 +00:00
systemd.services.charybdis = {
wantedBy = [ "multi-user.target" ];
2021-12-25 10:41:15 +00:00
after = [ "network-online.target" ];
2016-02-21 05:23:06 +00:00
environment = {
BANDB_DBPATH = "${cfg.user.home}/ban.db";
};
serviceConfig = {
SyslogIdentifier = "charybdis";
User = cfg.user.name;
PrivateTmp = true;
Restart = "always";
2021-12-25 10:41:15 +00:00
ExecStartPre = [
"${pkgs.coreutils}/bin/ln -s /etc/charybdis-ircd.motd /tmp/ircd.motd"
"${pkgs.coreutils}/bin/ln -s \${CREDENTIALS_DIRECTORY} /tmp/credentials"
];
2016-02-21 05:23:06 +00:00
ExecStart = toString [
2018-10-06 21:48:20 +00:00
"${pkgs.charybdis}/bin/charybdis"
2016-02-21 05:23:06 +00:00
"-configfile ${import ./config.nix args}"
"-foreground"
"-logfile /dev/stderr"
];
2021-12-25 10:41:15 +00:00
LoadCredential = [
"ssl_dh_params:${cfg.ssl_dh_params}"
"ssl_private_key:${cfg.ssl_private_key}"
];
2016-02-21 05:23:06 +00:00
};
};
users.users.${cfg.user.name} = {
2016-02-21 05:56:57 +00:00
inherit (cfg.user) home name uid;
2016-02-21 05:23:06 +00:00
createHome = true;
2021-12-23 23:48:23 +00:00
group = cfg.user.name;
2021-06-15 13:53:13 +00:00
isSystemUser = true;
2016-02-21 05:23:06 +00:00
};
2021-12-23 23:48:23 +00:00
users.groups.${cfg.user.name} = {};
2016-02-21 05:23:06 +00:00
};
}