about summary refs log tree commit diff
path: root/modules/services/cinny-web.nix
blob: e796ff8fe8e4f328ae0c64ad86a415655b7f0238 (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
{ config, lib, pkgs, ... }:

with lib;
let
  cfg = config.modules.services.cinny-web;
in
{
  options.modules.services.cinny-web = {
    enable = mkEnableOption "cinny-web";
    package = mkOption { type = types.package; default = pkgs.cinny; };
    hostName = mkOption { type = types.str; default = config.networking.hostName; };
    matrix.serverName = mkOption { type = types.str; default = config.networking.hostName; };
    tls.acmeHost = mkOption { type = types.str; default = cfg.hostName; };
  };

  config = mkIf cfg.enable {
    services.nginx.virtualHosts.${cfg.hostName} = {
      useACMEHost = cfg.tls.acmeHost;
      forceSSL = true;

      root = cfg.package.override {
        conf = {
          # Index of the default homeserver from `homeserverList`
          defaultHomeserver = 0;
          homeserverList = [ cfg.matrix.serverName ];
        };
      };

      locations."~ \\.(js|css|woff|woff2?|png|jpe?g|svg)$".extraConfig = ''
        add_header Cache-Control "public, max-age=14400, must-revalidate";
      '';
    };
  };
}