matrix: drop c0re /matrix mount, use targetFlags --base-href, surface availability via env (mara on #634)

This commit is contained in:
damocles 2026-05-30 14:56:52 +02:00
commit effe00889f
3 changed files with 44 additions and 51 deletions

View file

@ -241,6 +241,15 @@ in
# Agents poll this URL for Forgejo notifications. Derived from
# services.hyperhive.forge.{domain,httpPort} so it tracks forge config changes.
HIVE_FORGE_URL = "http://${config.services.hyperhive.forge.domain}:${toString config.services.hyperhive.forge.httpPort}";
}
// lib.optionalAttrs config.services.hyperhive.matrix.gui.enable {
# Availability flag for `/api/state.matrix_gui_enabled`. The
# gateway (hive-gateway.nix) does the actual static serving of
# fluffychat-web at `/matrix/`; c0re doesn't host the dist
# itself (#634, mara on PR #620). This env var just tells the
# dashboard chrome whether the GUI is reachable so iris's
# `M4TR1X →` tab doesn't show when the GUI is off.
HIVE_MATRIX_GUI_ENABLED = "1";
};
# Matrix GUI static serving lives entirely on the hive-gateway
# nginx since #609 — when gateway is off the operator opts out

View file

@ -183,34 +183,30 @@ in
type = lib.types.package;
default = pkgs.fluffychat-web.overrideAttrs (old: {
# fluffychat-web ships with `<base href="/">` 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
# `<base href="/">` 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 `<base href="/matrix/">` 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|<base href="/">|<base href="/matrix/">|' \
$out/index.html
'';
# index.html — flutter's `--base-href` build flag replaces
# that placeholder. Default upstream build is `--base-href "/"`
# which is wrong for hyperhive's `/matrix/` sub-path mount:
# the browser resolves relative asset paths (`Imaging.js`,
# `flutter.js`, `splash/*`) against the document ROOT,
# producing 404s for every asset (#634). Inject the right
# base-href into the build via nixpkgs's `buildFlutterApplication`
# targetFlags. When subdomain routing lands (#609 —
# `matrix.${hyperhiveDomain}`), drop this override; upstream's
# `/` base-href is correct at the root of a dedicated subdomain.
targetFlags = (old.targetFlags or [ ]) ++ [
"--base-href"
"/matrix/"
];
});
defaultText = lib.literalExpression "pkgs.fluffychat-web (patched for /matrix/ base href)";
defaultText = lib.literalExpression "pkgs.fluffychat-web with --base-href /matrix/";
description = ''
Static web client dist to serve at `/matrix/`. Defaults to
`pkgs.fluffychat-web` (with the `<base href>` 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 `<base href>` aligned with the
mount path.
`pkgs.fluffychat-web` rebuilt with `--base-href "/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 `<base href>` aligned with the mount path.
'';
};
};