summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/ergo.nix
blob: 0ce0345d83dbf0b502ee997191c00a7434b8b46a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{ config, lib, options, pkgs, ... }: {
  options = {
    krebs.ergo = {
      enable = lib.mkEnableOption "Ergo IRC daemon";
      config = lib.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 = {
            path = "/var/lib/ergo/ircd.db";
          };
          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;
          };
        };
      };
    };
  };
  config = let
    cfg = config.krebs.ergo;
    configFile = pkgs.writeJSON "ergo.conf" cfg.config;
  in lib.mkIf cfg.enable ({
    krebs.ergo.config =
      lib.mapAttrsRecursive (_: lib.mkDefault) options.krebs.ergo.config.default;
    systemd.services.ergo = {
      description = "Ergo IRC daemon";
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        ExecStart = "${pkgs.ergo}/bin/ergo run --conf ${configFile}";
        DynamicUser = true;
        StateDirectory = "ergo";
      };
    };
  });
}