nix: hive-gateway v0 — nginx in front of c0re (#609)
Per mara's directive on #609: stand up a single nginx in its own nixos-container, serve the matrix GUI static dist there, proxy everything else to hive-c0re. v0 is HTTP-only; TLS / public-domain shape lands in follow-ups. New `nix/modules/hive-gateway.nix` declaring `containers.hive-gateway` modelled on `hive-forge`: - nixos-container running nginx, shares host netns - `location /matrix/` → static-serves `hyperhive.matrix.gui.package` (fluffychat-web by default) when `matrix.gui.enable` is true - `location /` → proxy_pass to `127.0.0.1:${dashboardPort}` with websocket + SSE upgrade headers + 1d read timeout Options (`hyperhive.gateway.*`): - `enable` (default `true`) — gateway on by default, opt out to bypass - `port` (default `80`) — nginx listen port on the host - `upstreamHost` / `upstreamPort` — c0re target, defaults to `127.0.0.1:${services.hive-c0re.dashboardPort}` - `openFirewall` (default `true`) — open the listen port - `localHostsEntry` (default `false`) — when true, adds an `/etc/hosts` entry mapping `hyperhive.domain` → `127.0.0.1` for local-dev / test loops without real DNS (per mara's spec) `hive-c0re.nix` updates: when gateway is enabled, skip wiring `HIVE_MATRIX_GUI_DIR` (gateway owns `/matrix/` now). When gateway is off, c0re's pre-existing matrix mount stays as the fallback. README: short "Optional" block introducing the gateway + the `localHostsEntry` knob. ```sh nix flake check --no-build nix build .#docs-host ``` End-to-end eval matrix: | gateway.enable | matrix.gui.enable | c0re HIVE_MATRIX_GUI_DIR | gateway container | | --- | --- | --- | --- | | true (default) | true | unset (gateway serves) | present | | true | false | unset | present, no /matrix | | false | true | set (c0re serves) | absent | | false | false | unset | absent | - TLS termination — separate follow-up once mara picks a story (self-signed-mkcert vs operator-provided certs) - Per-agent UI routing (`/agent/<name>/`) — depends on agent base-path support which is a frontend lift - Subdomain routing for `matrix.${hyperhive.domain}` — same-origin `/matrix/` is the v0 shape per mara ("leave everything else as is") Closes part of #609 (matrix GUI re-rooting onto nginx); leaves the issue open for the subdomain re-root + `.well-known/matrix/client` piece once the multi-host story matures.
This commit is contained in:
parent
1a839d45e3
commit
b37c353f0e
3 changed files with 203 additions and 8 deletions
|
|
@ -23,6 +23,7 @@ in
|
|||
# is set before it can be enabled.
|
||||
imports = [
|
||||
./hive-forge.nix
|
||||
./hive-gateway.nix
|
||||
./hive-matrix.nix
|
||||
];
|
||||
|
||||
|
|
@ -230,14 +231,12 @@ 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 {
|
||||
# Optional matrix-GUI static dist mounted at /matrix/ by the
|
||||
# dashboard router (#607 v0). Pre-#15 / pre-nginx-front: this is
|
||||
# the simplest same-origin shape — fluffychat-web ships as a
|
||||
# static dist, no runtime daemon needed.
|
||||
HIVE_MATRIX_GUI_DIR = "${config.services.hyperhive.matrix.gui.package}";
|
||||
};
|
||||
# Matrix GUI static serving lives entirely on the hive-gateway
|
||||
# nginx since #609 — when gateway is off the operator opts out
|
||||
# of matrix-GUI serving entirely (mara on PR #620: "if you
|
||||
# disable gateway you have to static host that yourself
|
||||
# somewhere"). c0re no longer touches /matrix/.
|
||||
serviceConfig = {
|
||||
ExecStart = "${cfg.package}/bin/hive-c0re --socket /run/hyperhive/host.sock serve --hyperhive-flake ${cfg.hyperhiveFlake} --dashboard-port ${toString cfg.dashboardPort} --operator-pronouns ${lib.escapeShellArg cfg.operatorPronouns} --context-window-tokens ${lib.escapeShellArg (builtins.toJSON cfg.contextWindowTokens)}";
|
||||
Restart = "on-failure";
|
||||
|
|
|
|||
Loading…
Reference in a new issue