about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2023-04-04 22:19:22 +0900
committersefidel <contact@sefidel.net>2023-04-04 22:19:22 +0900
commit5fb9453d3e900c5b907ba67d9267f06764fadbbd (patch)
tree359608e9452fd5a0c521d3b04afad79f3eb195e3
parent09c5d5d6a4ef8315b99fc53be21de22b0e8121f8 (diff)
downloadinfra-5fb9453d3e900c5b907ba67d9267f06764fadbbd.tar.gz
infra-5fb9453d3e900c5b907ba67d9267f06764fadbbd.zip
feat(services/schildichat-web): init
-rw-r--r--modules/services/schildichat-web.nix47
-rw-r--r--systems/cobalt/default.nix11
2 files changed, 58 insertions, 0 deletions
diff --git a/modules/services/schildichat-web.nix b/modules/services/schildichat-web.nix
new file mode 100644
index 0000000..8a8ede5
--- /dev/null
+++ b/modules/services/schildichat-web.nix
@@ -0,0 +1,47 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.modules.services.schildichat-web;
+in
+{
+  options.modules.services.schildichat-web = {
+    enable = mkEnableOption "schildichat-web";
+    package = mkOption { type = types.package; default = pkgs.schildichat-web; };
+    hostName = mkOption { type = types.str; default = config.networking.hostName; };
+    matrix = {
+      baseUrl = mkOption { type = types.str; default = "https://matrix.${config.networking.hostName}"; };
+      serverName = mkOption { type = types.str; default = config.networking.hostName; };
+    };
+    tls.acmeHost = mkOption { type = types.str; default = cfg.hostName; };
+    jitsi.domain = mkOption { type = types.str; default = "jitsi.${cfg.hostName}"; };
+  };
+
+  config = mkIf cfg.enable {
+    services.nginx.virtualHosts.${cfg.hostName} = {
+      useACMEHost = cfg.tls.acmeHost;
+      forceSSL = true;
+
+      root = cfg.package.override {
+        conf = {
+          default_server_config = {
+            "m.homeserver" = {
+              "base_url" = cfg.matrix.baseUrl;
+              "server_name" = cfg.matrix.serverName;
+            };
+            "m.identity_server" = {
+              "base_url" = "https://vector.im";
+            };
+          };
+          showLabsSettings = true;
+        } // optionalAttrs (cfg.jitsi.domain != null) {
+          jitsi.preferredDomain = cfg.jitsi.domain;
+        };
+      };
+
+      locations."~ \\.(js|css|woff|woff2?|png|jpe?g|svg)$".extraConfig = ''
+        add_header Cache-Control "public, max-age=14400, must-revalidate";
+      '';
+    };
+  };
+}
diff --git a/systems/cobalt/default.nix b/systems/cobalt/default.nix
index f369fec..d9a279b 100644
--- a/systems/cobalt/default.nix
+++ b/systems/cobalt/default.nix
@@ -174,6 +174,7 @@ in
             "bouncer"
             "meet"
             "chat"
+            "schildi"
             "turn"
             "status"
             "mail"
@@ -246,6 +247,16 @@ in
       tls.acmeHost = "exotic.sh";
       jitsi.domain = "meet.exotic.sh";
     };
+    services.schildichat-web = {
+      enable = true;
+      hostName = "schildi.exotic.sh";
+      matrix = {
+        baseUrl = config.modules.services.element-web.matrix.baseUrl;
+        serverName = config.modules.services.element-web.matrix.serverName;
+      };
+      tls.acmeHost = config.modules.services.element-web.tls.acmeHost;
+      jitsi.domain = config.modules.services.element-web.jitsi.domain;
+    };
     services.akkoma = {
       enable = true;
       domain = "exotic.sh";