{ 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; host = full-domain; siteName = "CompSciClub"; dataDir = "/srv/mattermost"; }; services.caddy.virtualHosts.${full-domain}.extraConfig = '' reverse_proxy http://127.0.0.1:8065 {} ''; }; }