summaryrefslogtreecommitdiff
path: root/modules/soju/sys.nix
blob: 83c3560e22f3f71126e0cccd222617aee0600386 (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
{
  config,
  pkgs,
  lib,
  cfg,
  doctrine,
  ...
}:
with lib; {
  security.acme.certs."${cfg.fullyQualifiedDomain}" = {
    reloadServices = ["soju.service"];
    group = "soju";
  };

  networking.firewall.allowedTCPPorts = [cfg.port];

  services.soju = let
    sojuCertDir = config.security.acme.certs."${cfg.fullyQualifiedDomain}".directory;
  in {
    enable = true;
    hostName = "${cfg.fullyQualifiedDomain}";
    listen = ["ircs://[::]:${toString cfg.port}"];
    tlsCertificate = "${sojuCertDir}/fullchain.pem";
    tlsCertificateKey = "${sojuCertDir}/key.pem";
  };

  systemd.services.soju = {
    after = ["acme-${cfg.fullyQualifiedDomain}.service"];
    serviceConfig = {
      DynamicUser = mkForce false; # fuck dynamic users
      User = "soju";
      Group = "soju";
      ProtectSystem = "strict";
      ProtectHome = "read-only";
      PrivateTmp = true;
      RemoveIPC = true;
    };
  };

  users = {
    users.soju = {
      isSystemUser = true;
      group = "soju";
    };
    groups.soju = {};
  };
}