58 lines
2.6 KiB
Nix
58 lines
2.6 KiB
Nix
# Stylix theme integration (zero-op auto-detect). When the operator's
|
|
# host config has stylix enabled, generate a base16 `colors.css` from
|
|
# its palette and overlay it onto the bundled frontend dist so the
|
|
# dashboard re-themes with no operator action and no npm/esbuild
|
|
# rebuild (a pure file-copy over the prebuilt dist). `colors.css` is
|
|
# the entire swap contract — `theme.css` derives every semantic var
|
|
# from the 16 base16 slots (see docs/web-ui/css-vars.md). The guarded
|
|
# access makes this a clean no-op when stylix isn't imported into the
|
|
# host config. Exposed as the read-only `deploy.hive-controller.servedFrontend` option.
|
|
#
|
|
# Detection + CSS-generation itself lives in `../stylix-theme.nix`
|
|
# (shared with `swarm-ui.nix`) — this file is the c0re-specific overlay
|
|
# consumer (which subtrees, which option).
|
|
{
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.services.hyperhive.deploy.hive-controller;
|
|
stylixTheme = import ../stylix-theme.nix { inherit lib config pkgs; };
|
|
inherit (stylixTheme) stylixThemeColors themedColorsCss;
|
|
# Overlay the generated colors.css onto both dist subtrees. Both the
|
|
# dashboard (served by hive-c0re via HIVE_STATIC_DIR) and the agent UIs
|
|
# (served by the gateway from HIVE_AGENT_FRONTEND_DIR — static files
|
|
# straight from the store) read their colors.css from this host-side
|
|
# tree, so swapping both re-themes both surfaces.
|
|
#
|
|
# Not covered here: an agent reached directly on its own harness web
|
|
# server (no gateway) serves from its per-agent `mergedDist`, built in
|
|
# the agent's own nixosSystem with no access to the host's stylix
|
|
# colours — theming that path needs the base16 palette forwarded
|
|
# host→agent, tracked separately.
|
|
themedFrontend =
|
|
c:
|
|
pkgs.runCommand "hyperhive-frontend-themed" { } ''
|
|
cp -r ${cfg.frontend} $out
|
|
chmod -R u+w $out
|
|
install -m644 ${themedColorsCss c} $out/dashboard/static/colors.css
|
|
install -m644 ${themedColorsCss c} $out/agent/static/colors.css
|
|
'';
|
|
in
|
|
{
|
|
options.services.hyperhive.deploy.hive-controller.servedFrontend = lib.mkOption {
|
|
type = lib.types.package;
|
|
internal = true;
|
|
readOnly = true;
|
|
default = if stylixThemeColors != null then themedFrontend stylixThemeColors else cfg.frontend;
|
|
defaultText = lib.literalExpression "<stylix-themed overlay of `frontend`>";
|
|
description = ''
|
|
Internal, read-only: `frontend` re-themed with the active stylix
|
|
palette (or `frontend` verbatim when unthemed); has `dashboard/`
|
|
and `agent/`. Exposed so the hive-gateway module can static-serve
|
|
`dashboard/` as an nginx root instead of proxying to hive-c0re.
|
|
'';
|
|
};
|
|
}
|