hive-gateway: serve the swagger-ui theme via nginx alias, not a c0re build hook
This commit is contained in:
parent
5471b49f2a
commit
de1659d10e
7 changed files with 117 additions and 8 deletions
|
|
@ -65,6 +65,19 @@
|
|||
processes to their icon.
|
||||
'';
|
||||
};
|
||||
swaggerUiTheme = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
defaultText = lib.literalExpression "hyperhive.packages.\${system}.swagger-ui-theme";
|
||||
description = ''
|
||||
Swagger UI re-theme static override files (see
|
||||
`nix/packages/swagger-ui-theme.nix`; output has `index.html` +
|
||||
`hyperhive-theme.css`). The hive-gateway module `alias`es these
|
||||
two files straight from the store over `/api/docs/`, so a theme
|
||||
tweak is a gateway config change — hive-c0re's own vendored
|
||||
Swagger UI build is untouched. Override to ship a custom theme
|
||||
(or the vendored default) without a hive-c0re rebuild.
|
||||
'';
|
||||
};
|
||||
hyperhiveFlake = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
defaultText = lib.literalMD "the hyperhive flake's own filtered source store path";
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ let
|
|||
# container's).
|
||||
dashboardDist = "${config.services.hyperhive.c0re.servedFrontend}/dashboard";
|
||||
|
||||
# Swagger UI re-theme static override files — nginx `alias`es these
|
||||
# straight from the store over `/api/docs/`, so a theme tweak ships
|
||||
# as a gateway config change (see vhosts.nix's `swaggerThemeLocations`
|
||||
# and nix/packages/swagger-ui-theme.nix).
|
||||
swaggerUiTheme = config.services.hyperhive.c0re.swaggerUiTheme;
|
||||
|
||||
# Self-signed TLS is the implicit floor: when neither an operator cert
|
||||
# (`tls.certDir`) nor ACME (`tls.acme.enable`) is configured, the gateway
|
||||
# generates + serves a hive-CA-signed leaf (see hive-tls.nix). There is no
|
||||
|
|
@ -261,6 +267,7 @@ in
|
|||
matrixCfg
|
||||
hyperhiveDomain
|
||||
dashboardDist
|
||||
swaggerUiTheme
|
||||
tlsCert
|
||||
tlsKey
|
||||
;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
matrixCfg,
|
||||
hyperhiveDomain,
|
||||
dashboardDist,
|
||||
swaggerUiTheme, # nix/packages/swagger-ui-theme.nix: has index.html + hyperhive-theme.css
|
||||
errorPages, # ./error-pages.nix: { notFound, unreachable, unauthorized }
|
||||
tlsCert,
|
||||
tlsKey,
|
||||
|
|
@ -304,6 +305,33 @@ let
|
|||
proxyPass = "http://${cfg.upstreamHost}:${toString cfg.upstreamPort}";
|
||||
};
|
||||
};
|
||||
|
||||
# Swagger UI re-theme: exact-match locations `alias`ed straight to
|
||||
# `swaggerUiTheme`'s store path, nginx-served with no involvement
|
||||
# from hive-c0re at all. `=` locations win over the `/api/` prefix
|
||||
# block above regardless of declaration order (nginx's own location-
|
||||
# matching precedence — exact match beats longest-prefix), so this
|
||||
# doesn't need to be declared before it. Every OTHER Swagger UI asset
|
||||
# (bundle.js, openapi.json, favicons, the *vendored* index.html c0re
|
||||
# would otherwise serve) still falls through `/api/` to c0re's own
|
||||
# embedded `utoipa-swagger-ui` dist unchanged — only these two exact
|
||||
# paths are intercepted. A theme tweak is therefore a change to
|
||||
# `hive-c0re/swagger-ui-theme/` + a gateway container activation, not
|
||||
# a hive-c0re rebuild+restart. See nix/packages/swagger-ui-theme.nix.
|
||||
swaggerThemeLocations = {
|
||||
"= /api/docs/" = {
|
||||
extraConfig = ''
|
||||
alias ${swaggerUiTheme}/index.html;
|
||||
${dashboardAuth}
|
||||
'';
|
||||
};
|
||||
"= /api/docs/hyperhive-theme.css" = {
|
||||
extraConfig = ''
|
||||
alias ${swaggerUiTheme}/hyperhive-theme.css;
|
||||
${dashboardAuth}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
# Accept-header SPA map for the matrix GUI only (see docs/gateway.md
|
||||
|
|
@ -325,6 +353,7 @@ in
|
|||
// wellKnownLocations
|
||||
// agentLocations
|
||||
// dashboardProxyLocation
|
||||
// swaggerThemeLocations
|
||||
// lib.optionalAttrs cfg.auth.enable {
|
||||
# Internal-only target for the 401 error_page above.
|
||||
# `internal` prevents direct client access; `alias` serves
|
||||
|
|
|
|||
Loading…
Reference in a new issue