swarm-ui: apply the operator's stylix theme, same as the dashboard already does
mara: "swarm dash is in my own colors, but tab colors on swarm ui are the default catpucchin one." Root cause: hive-c0re/theme.nix's stylix overlay only ever wrote a themed colors.css onto the dashboard/agent frontend subtrees -- swarm-ui, served from its own separate package, was never in scope. Extracts the stylix-detection + colors.css-generation logic (previously inline in theme.nix) into a shared nix/host-modules/stylix-theme.nix, imported by both theme.nix and swarm-ui.nix -- one source instead of a second copy that has to agree by inspection. swarm-ui.nix gains its own themedPackage overlay (same shape as theme.nix's themedFrontend: copy the package, overwrite static/colors.css) and serves that instead of cfg.package directly when stylix is active; a clean passthrough otherwise. Verified with a throwaway nixosSystem eval (this repo's own flake checks do not exercise gateway-module wiring) confirming the unthemed path resolves cfg.package unchanged.
This commit is contained in:
parent
2e06957b32
commit
2ecf842a1b
3 changed files with 87 additions and 28 deletions
|
|
@ -9,6 +9,7 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
|
|
@ -17,6 +18,26 @@ let
|
|||
autheliaCfg = config.services.hyperhive.swarm.authelia;
|
||||
controllerCfg = config.services.hyperhive.swarm.controller;
|
||||
|
||||
# Same stylix auto-theming `hive-c0re/theme.nix` gives the dashboard —
|
||||
# this UI was left out of that overlay entirely (an operator with a
|
||||
# stylix-themed host saw the dashboard in their own colours but this
|
||||
# UI still on the default Catppuccin palette), because nothing here
|
||||
# ever wrote a themed `colors.css` over `cfg.package` before serving
|
||||
# it; the c0re-side overlay only ever touched `dashboard/`/`agent/`.
|
||||
# Detection + CSS-generation is shared (`./stylix-theme.nix`);
|
||||
# `servedPackage` is this module's own overlay-onto-`cfg.package`
|
||||
# consumer, same shape as `theme.nix`'s `themedFrontend`.
|
||||
stylixTheme = import ./stylix-theme.nix { inherit lib config pkgs; };
|
||||
inherit (stylixTheme) stylixThemeColors themedColorsCss;
|
||||
themedPackage =
|
||||
c:
|
||||
pkgs.runCommand "hyperhive-swarm-ui-themed" { } ''
|
||||
cp -r ${cfg.package} $out
|
||||
chmod -R u+w $out
|
||||
install -m644 ${themedColorsCss c} $out/static/colors.css
|
||||
'';
|
||||
servedPackage = if stylixThemeColors != null then themedPackage stylixThemeColors else cfg.package;
|
||||
|
||||
# Repeated verbatim by every location that should be operator-gated
|
||||
# (`/`, `/api/`, `/api/docs/`) rather than set once on the server:
|
||||
# nginx's `auth_request` does NOT inherit across sibling locations, so
|
||||
|
|
@ -170,7 +191,7 @@ in
|
|||
extraConfig = gatewayCfg.lib.securityHeaders;
|
||||
locations = {
|
||||
"/" = {
|
||||
root = "${cfg.package}";
|
||||
root = "${servedPackage}";
|
||||
extraConfig = ''
|
||||
${swarmAuthRequest}
|
||||
# SPA: any path the bundle routes client-side is served the
|
||||
|
|
|
|||
Loading…
Reference in a new issue