about summary refs log tree commit diff
path: root/ops/modules/quassel.nix
blob: 6acb0615f4c0ce88e81ad2e8d620dbfbbba31da3 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# A more modern module for running Quassel.
{ config, lib, pkgs, ... }:

let
  cfg = config.services.depot.quassel;
  quasselDaemon = pkgs.quassel.override {
    monolithic = false;
    enableDaemon = true;
    withKDE = false;
  };
in
{
  options.services.depot.quassel = with lib; {
    enable = mkEnableOption "Quassel IRC daemon";

    acmeHost = mkOption {
      description = "ACME host to use for the Quassel TLS certificate";
      type = lib.types.str;
    };

    bindAddresses = mkOption {
      description = "Addresses Quassel will bind to/listen on";
      default = [ "127.0.0.1" ];
    };

    logLevel = mkOption {
      description = "Log level for Quassel Core";
      default = "Info";
      type = lib.types.enum [
        "Debug"
        "Info"
        "Warning"
        "Error"
      ];
    };

    port = mkOption {
      default = 6698;
      description = ''
        The port number the Quassel daemon will be listening to.
      '';
    };
  };

  config = with lib; mkIf cfg.enable {
    networking.firewall.allowedTCPPorts = [ cfg.port ];

    systemd.services.quassel = {
      description = "Quassel IRC daemon";
      wantedBy = [ "multi-user.target" ];

      script = concatStringsSep " " [
        "${quasselDaemon}/bin/quasselcore"
        "--listen=${concatStringsSep "," cfg.bindAddresses}"
        "--port=${toString cfg.port}"
        "--configdir=/var/lib/quassel"
        "--require-ssl"
        "--ssl-cert=$CREDENTIALS_DIRECTORY/quassel.pem"
        "--loglevel=${cfg.logLevel}"
      ];

      serviceConfig = {
        Restart = "always";
        User = "quassel";
        Group = "quassel";
        StateDirectory = "quassel";

        # Avoid trouble with the ACME file permissions by using the
        # systemd credentials feature.
        LoadCredential = "quassel.pem:/var/lib/acme/${cfg.acmeHost}/full.pem";
      };
    };

    users = {
      users.quassel = {
        isSystemUser = true;
        group = "quassel";
      };

      groups.quassel = { };
    };
  };
}