summaryrefslogtreecommitdiff
path: root/nixos/modules/homelab/communications/mattermost.nix
blob: db3f759b615994331816b53e20f3918085b6d387 (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
{ config, lib, ... }: let
  cfg = config.homelab.communications.mattermost;
  full-domain = lib.strings.concatStrings [cfg.subdomain "." cfg.domain];
in {
  options.homelab.communications.mattermost = {
    enable = lib.mkEnableOption "mattermost";
    domain = lib.mkOption {
      description = "The domain under which to serve the mattermost server.";
      type = lib.types.str;
      default = config.networking.domain;
      example = "example.com";
    };
    subdomain = lib.mkOption {
      description = "The subdomain under which to serve the mattermost server.";
      type = lib.types.str;
      default = "mattermost";
      example = "chat";
    };
  };
  config = lib.mkIf cfg.enable {
    services.mattermost = {
      enable = true;
      siteName = "CS Club";
      siteUrl = "https://${full-domain}";
      dataDir = "/srv/mattermost";
      settings = {
        TeamSettings = {
          EnableOpenServer = true;
        };
      };
    };
    services.caddy.virtualHosts.${full-domain}.extraConfig = ''
      reverse_proxy http://127.0.0.1:8065
    '';
  };
}