diff --git a/nix/modules/hive-gateway.nix b/nix/modules/hive-gateway.nix index 09b02a13..b497426b 100644 --- a/nix/modules/hive-gateway.nix +++ b/nix/modules/hive-gateway.nix @@ -275,6 +275,36 @@ in try_files $uri $uri/ $matrix_spa_target =404; ''; }; + # FluffyChat fetches `/matrix/config.json` directly on + # boot for its own branding + default-homeserver + # bootstrap, BEFORE asking the user to pick a server + # (#736). The upstream `pkgs.fluffychat-web` dist + # ships without one, so the fetch 404s and the user + # sees the empty "enter homeserver" prompt. Serve a + # minimal config that pre-fills `defaultHomeserver` + # with the operator's hive domain — the matrix + # client then runs `.well-known/matrix/client` against + # that domain (already served by the + # `= /.well-known/matrix/client` block below) and + # discovers the actual tuwunel endpoint. + # + # Only the `defaultHomeserver` field is overridden — + # everything else (branding, audio defaults, etc.) + # falls back to fluffychat's hardcoded defaults so + # we don't pin against upstream config-schema drift. + # No-op when `services.hyperhive.domain` is unset + # (the location block is omitted entirely; the SPA + # then falls back to its empty form, same as before + # #736). + } // lib.optionalAttrs ( + matrixCfg.enable && matrixCfg.gui.enable && hyperhiveDomain != null + ) { + "= /matrix/config.json" = { + extraConfig = '' + default_type application/json; + return 200 '{"defaultHomeserver":"${hyperhiveDomain}"}'; + ''; + }; } // # `.well-known/matrix/*` auto-discovery (#660): when