summaryrefslogtreecommitdiffstats
path: root/tv/3modules/charybdis/default.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-02-22 14:35:59 +0100
committermakefu <github@syntax-fehler.de>2016-02-22 14:35:59 +0100
commitb25d15573ab10a4b2dd55e46291fbab6adf70162 (patch)
tree1036547a8003c5767565d53d748d83d3614271b6 /tv/3modules/charybdis/default.nix
parent5b7039f1f11e7cf2da6f3735cc7d99322a31c7a5 (diff)
parent8393444dce1888d369955e46dd16983a43762bb9 (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'tv/3modules/charybdis/default.nix')
-rw-r--r--tv/3modules/charybdis/default.nix80
1 files changed, 80 insertions, 0 deletions
diff --git a/tv/3modules/charybdis/default.nix b/tv/3modules/charybdis/default.nix
new file mode 100644
index 000000000..3af971cd4
--- /dev/null
+++ b/tv/3modules/charybdis/default.nix
@@ -0,0 +1,80 @@
+{ config, lib, pkgs, ... }@args: with config.krebs.lib; let
+ 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 {
+ type = types.secret-file;
+ default = {
+ path = "${cfg.user.home}/dh.pem";
+ owner = cfg.user;
+ source-path = toString <secrets> + "/charybdis.dh.pem";
+ };
+ };
+ ssl_private_key = mkOption {
+ type = types.secret-file;
+ default = {
+ path = "${cfg.user.home}/ssl.key.pem";
+ owner = cfg.user;
+ source-path = toString <secrets> + "/charybdis.key.pem";
+ };
+ };
+ sslport = mkOption {
+ type = types.int;
+ default = 6697;
+ };
+ user = mkOption {
+ type = types.user;
+ default = {
+ name = "charybdis";
+ home = "/var/lib/charybdis";
+ };
+ };
+ };
+ config = lib.mkIf cfg.enable {
+
+ krebs.secret.files.charybdis-ssl_dh_params = cfg.ssl_dh_params;
+ krebs.secret.files.charybdis-ssl_private_key = cfg.ssl_private_key;
+
+ environment.etc."charybdis-ircd.motd".text = cfg.motd;
+
+ systemd.services.charybdis = {
+ wantedBy = [ "multi-user.target" ];
+ requires = [ "secret.service" ];
+ after = [ "network.target" "secret.service" ];
+ environment = {
+ BANDB_DBPATH = "${cfg.user.home}/ban.db";
+ };
+ serviceConfig = {
+ SyslogIdentifier = "charybdis";
+ User = cfg.user.name;
+ PrivateTmp = true;
+ Restart = "always";
+ ExecStartPre =
+ "${pkgs.coreutils}/bin/ln -s /etc/charybdis-ircd.motd /tmp/ircd.motd";
+ ExecStart = toString [
+ "${pkgs.charybdis}/bin/charybdis-ircd"
+ "-configfile ${import ./config.nix args}"
+ "-foreground"
+ "-logfile /dev/stderr"
+ ];
+ };
+ };
+
+ users.users.${cfg.user.name} = {
+ inherit (cfg.user) home name uid;
+ createHome = true;
+ };
+ };
+}