From 8e9b074467006c76768efe04cf1fb1ef9d652c67 Mon Sep 17 00:00:00 2001 From: sefidel Date: Wed, 24 Jan 2024 13:29:27 +0900 Subject: initial commit --- modules/services/cinny-web.nix | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 modules/services/cinny-web.nix (limited to 'modules/services/cinny-web.nix') diff --git a/modules/services/cinny-web.nix b/modules/services/cinny-web.nix new file mode 100644 index 0000000..e796ff8 --- /dev/null +++ b/modules/services/cinny-web.nix @@ -0,0 +1,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"; + ''; + }; + }; +} -- cgit 1.4.1