aboutsummaryrefslogtreecommitdiff
path: root/modules/private/irc.nix
blob: 9871508041f870238e569316a051a689eaaedb36 (plain) (blame)
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
{ lib, pkgs, config, ... }:
let
  cfg = config.myServices.irc;
in
{
  options.myServices = {
    ircCerts = lib.mkOption {
      description = "Default ircconfigurations for certificates as accepted by acme";
    };
    irc.enable = lib.mkOption {
      type = lib.types.bool;
      default = false;
      description = ''
        Whether to enable irc stuff.
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    services.duplyBackup.profiles.irc = {
      rootDir = "/var/lib/bitlbee";
    };
    security.acme.certs."irc" = config.myServices.ircCerts // {
      domain = "irc.immae.eu";
      postRun = ''
        systemctl restart stunnel.service
      '';
    };

    networking.firewall.allowedTCPPorts = [ 6697 ];
    services.bitlbee = with pkgs; {
      enable = true;
      authMode = "Registered";
      libpurple_plugins = [
        purple-hangouts
        purple-matrix
      ];
      plugins = [
        bitlbee-mastodon
        bitlbee-facebook
        bitlbee-discord
        bitlbee-steam
      ];
    };

    services.stunnel = {
      enable = true;
      servers = {
        bitlbee = {
          accept = 6697;
          connect = 6667;
          cert = "${config.security.acme.certs.irc.directory}/full.pem";
        };
      };
    };
  };
}