From 433c972db1d18e288a5fc69ef5fc327f1f6632a9 Mon Sep 17 00:00:00 2001 From: damocles Date: Sat, 30 May 2026 14:41:21 +0200 Subject: [PATCH] matrix: default gui.enable to matrix.enable + patch fluffychat-web base href for /matrix/ subpath (#634) --- nix/modules/hive-matrix.nix | 46 ++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/nix/modules/hive-matrix.nix b/nix/modules/hive-matrix.nix index a2ef7abe..3b0a820d 100644 --- a/nix/modules/hive-matrix.nix +++ b/nix/modules/hive-matrix.nix @@ -159,14 +159,17 @@ in gui = { enable = lib.mkOption { type = lib.types.bool; - default = false; + default = cfg.enable; + defaultText = lib.literalExpression "config.services.hyperhive.matrix.enable"; description = '' Mount a matrix web client (default `pkgs.fluffychat-web`) as a static sibling of the dashboard at `/matrix/`, served by hive-c0re's own axum router via the `HIVE_MATRIX_GUI_DIR` - env var (#607 v0). Off by default; flip to `true` once the - operator wants matrix chat one tab away from the dashboard - without standing up a separate gateway. + env var (#607). Defaults to whatever + `services.hyperhive.matrix.enable` is — turning on the + homeserver gives you the web client by default; set to + `false` explicitly to opt out of the GUI while keeping + the homeserver running for agents. Same-origin via hive-c0re is the simplest single-host shape; the post-#15 nginx-front re-root (`https://matrix.''${services.hyperhive.domain}`) @@ -178,15 +181,36 @@ in package = lib.mkOption { type = lib.types.package; - default = pkgs.fluffychat-web; - defaultText = lib.literalExpression "pkgs.fluffychat-web"; + default = pkgs.fluffychat-web.overrideAttrs (old: { + # fluffychat-web ships with `` baked into its + # index.html — that's the placeholder flutter would replace + # via `--base-href` at build time. Since hyperhive serves the + # dist at `/matrix/` (not the document root), the literal + # `` would resolve every relative asset path + # (`Imaging.js`, `flutter.js`, `splash/*`, etc.) against the + # ROOT of the origin, leading to 404s on every load (#634). + # Patch the placeholder to `` at install + # time so the SPA boots correctly under the sub-path mount. + # If/when we move to subdomain routing (#609 − + # `matrix.${hyperhiveDomain}`), drop this override and revert + # to upstream `pkgs.fluffychat-web` — it'll be at the root + # again. + postInstall = (old.postInstall or "") + '' + ${pkgs.gnused}/bin/sed -i \ + 's|||' \ + $out/index.html + ''; + }); + defaultText = lib.literalExpression "pkgs.fluffychat-web (patched for /matrix/ base href)"; description = '' Static web client dist to serve at `/matrix/`. Defaults to - `pkgs.fluffychat-web` — first-class threads support, e2ee - + voice + spaces, full feature surface in the flutter→web - build. Override to swap for `hydrogen-web` (lightest), - `cinny` (no threads), `element-web` (heaviest, full - features), or an out-of-tree client dist. + `pkgs.fluffychat-web` (with the `` patched to + `/matrix/` so relative asset paths resolve under the + sub-path mount, #634). Override to swap for `hydrogen-web` + (lightest), `cinny` (no threads), `element-web` (heaviest, + full features), or an out-of-tree client dist — any + replacement also needs its `` aligned with the + mount path. ''; }; };