gateway: nginx-hosts the full Swagger UI dist, core drops the fallback
Extends the theme-only alias into the full shape mara asked for on the
PR thread:
1. nix/packages/swagger-ui-dist.nix — plain vendored Swagger UI 5.17.14
dist, sourced directly from the swagger-ui-dist npm package (same
release the Rust utoipa-swagger-ui-vendored crate ships, verified
via matching gitHead commit) rather than through Cargo.lock/cargo.
2. nix/packages/swagger-ui-theme.nix — overlays our 3 override files
(index.html, hyperhive-theme.css, and now swagger-initializer.js)
onto (1).
3. vhosts.nix's swaggerUiLocations now prefix-matches the whole
/api/docs/ tree (not just 2 exact-match files) straight from (2),
plus a `= /api/docs` redirect shim since hive-c0re's own redirect
is going away too. /api/openapi.json (outside this prefix) keeps
proxying to c0re unchanged — that's the one thing that stays
dynamic.
New file swagger-initializer.js needed hand-verification: the plain
vendored copy hardcodes the swagger.io petstore demo URL.
utoipa-swagger-ui normally rewrites it per-request from a {{config}}
placeholder its own build.rs injects — since hive-c0re won't be
serving this file at all once its SwaggerUi mount is removed, that
rewrite has to be baked in statically here instead. Derived by
actually running build.rs's own two transforms (strip the default
layout: line, splice the Config JSON in place of the url/deepLinking
block) against the real vendored file, not typed from scratch —
verified byte-for-byte against what format_config() would produce for
hive-c0re's actual single-URL config, and checked with node --check.
Coordinated with damocles: he's taking the corresponding hive-c0re
side (drop the utoipa-swagger-ui dependency + SwaggerUi::new(...)
mount, keep only the plain /api/openapi.json route) once this lands.
Verified: nix fmt clean; nix build .#swagger-ui-theme succeeds, output
byte-matches the checked-in override files and node --check passes on
swagger-initializer.js; a full nixosSystem eval of nixosModules.default
resolves both new locations (/api/docs/ aliased to the right store
path, = /api/docs redirecting) with auth threaded through.
This commit is contained in:
parent
de1659d10e
commit
1bc9c18504
8 changed files with 166 additions and 76 deletions
|
|
@ -1,49 +1,58 @@
|
|||
{
|
||||
stdenv,
|
||||
swagger-ui-dist,
|
||||
}:
|
||||
|
||||
# The hand-authored Swagger UI re-theme files (`hive-c0re/swagger-ui-
|
||||
# theme/`), shipped as a standalone derivation so the gateway can
|
||||
# `alias` them straight from the nix store instead of hive-c0re's own
|
||||
# build serving them — see nix/host-modules/hive-gateway/vhosts.nix's
|
||||
# `swaggerThemeLocations`. This is what lets a CSS tweak ship as a
|
||||
# gateway config change (activate the gateway container) rather than a
|
||||
# hive-c0re rebuild+restart: the two files nginx exact-matches
|
||||
# (`/api/docs/` and `/api/docs/hyperhive-theme.css`) come from here;
|
||||
# every other Swagger UI asset (bundle.js, openapi.json, favicons, …)
|
||||
# still falls through the existing `/api/` prefix proxy to hive-c0re's
|
||||
# own vendored (unthemed) `utoipa-swagger-ui` embed, unchanged.
|
||||
# hyperhive's Catppuccin Mocha re-theme of Swagger UI: overlays our 3
|
||||
# hand-authored override files (`hive-c0re/swagger-ui-theme/`) onto
|
||||
# the plain vendored dist (./swagger-ui-dist.nix). This is the FULL
|
||||
# tree hive-gateway's nginx serves at `/api/docs/` — hive-c0re hosts
|
||||
# none of it, only the dynamic `/api/openapi.json` (see
|
||||
# nix/host-modules/hive-gateway/vhosts.nix).
|
||||
#
|
||||
# Pure data: copied verbatim, no build step.
|
||||
#
|
||||
# Output layout:
|
||||
# $out/index.html — themed index.html Swagger UI page
|
||||
# $out/hyperhive-theme.css — the re-theme, consumes --baseNN vars
|
||||
# from the dashboard's own colors.css
|
||||
# (loaded via an absolute /static/
|
||||
# colors.css <link>, same origin)
|
||||
|
||||
# Output layout: every file from `swagger-ui-dist`, with 3 replaced:
|
||||
# index.html — adds <link>s for colors.css (live stylix
|
||||
# theme, same origin) + hyperhive-theme.css
|
||||
# hyperhive-theme.css — new; the re-theme itself, consumes
|
||||
# --baseNN vars from colors.css
|
||||
# swagger-initializer.js — hardcodes `url: "/api/openapi.json"`. The
|
||||
# plain vendored copy points at the
|
||||
# swagger.io petstore demo; normally
|
||||
# `utoipa-swagger-ui`'s `serve()` rewrites
|
||||
# this file per-request from a `{{config}}`
|
||||
# placeholder it injects at its OWN build
|
||||
# time (see that crate's `build.rs`'s
|
||||
# `replace_default_url_with_config` +
|
||||
# `format_config`). hive-c0re no longer
|
||||
# serves this file at all, so that rewrite
|
||||
# has to happen here instead — this copy is
|
||||
# hand-verified to byte-match what
|
||||
# `format_config` would produce for
|
||||
# hive-c0re's actual config (single unnamed
|
||||
# url, otherwise all `Config` defaults): the
|
||||
# same transform applied to the real
|
||||
# vendored file, not hand-typed from
|
||||
# scratch.
|
||||
stdenv.mkDerivation {
|
||||
pname = "hyperhive-swagger-ui-theme";
|
||||
version = "0.1.0";
|
||||
# Narrow src keeps this derivation's input hash decoupled from the
|
||||
# rest of the tree — a theme tweak only re-hashes this.
|
||||
src = ../../hive-c0re/swagger-ui-theme;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
dontConfigure = true;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out
|
||||
cp -r ./* $out/
|
||||
cp -r ${swagger-ui-dist}/. $out/
|
||||
chmod -R u+w $out
|
||||
install -m644 ${../../hive-c0re/swagger-ui-theme/index.html} $out/index.html
|
||||
install -m644 ${../../hive-c0re/swagger-ui-theme/hyperhive-theme.css} $out/hyperhive-theme.css
|
||||
install -m644 ${../../hive-c0re/swagger-ui-theme/swagger-initializer.js} $out/swagger-initializer.js
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
dontFixup = true;
|
||||
|
||||
meta = {
|
||||
description = "hyperhive Swagger UI Catppuccin Mocha re-theme (static override files)";
|
||||
description = "hyperhive Swagger UI Catppuccin Mocha re-theme — full static dist, nginx-served at /api/docs/";
|
||||
homepage = "https://forge.darkest.space/hyperhive/hyperhive";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue