Project-bootstrap scope per the issue: static build as a nix pkg, empty start page for now, functionality deferred until auth against authelia is figured out. Stack (Preact + wouter + TypeScript + JSX) matches the shell decision from the earlier framework-paths thread — a real SPA shell with a router and deep links, distinct from the per-hive dashboard's vanilla-JS + custom-element MPA. - New npm workspace frontend/packages/swarm-ui: one route (/), a wouter Switch/Route shell, a 404 fallback. Reuses @hive/shared's colors.css/theme.css/base.css for visual consistency; no other shared JS (the vanilla-JS el()/dom.js helpers are superseded by Preact in this shell). - nix/packages/swarm-ui.nix: its own buildNpmPackage derivation (scoped to just this workspace via an explicit buildPhase), not folded into nix/packages/frontend.nix's packages.default closure — same reasoning swarm-controller/swarmctl already use for staying out of daemonBins: a hive that doesn't run the swarm controller shouldn't carry swarm-ui bytes. - npmDepsHash recomputed in both frontend.nix and swarm-ui.nix (same shared lockfile, new deps: preact, wouter-preact, typescript). - Added swarm-ui to nix/checks.nix alongside frontend, for the same FOD-staleness reason plus being the only thing that actually builds it in CI (not in packages.default's closure like frontend is, so nix flake check wouldn't otherwise touch it). - npm run typecheck (tsc --noEmit) is available locally; not yet wired into CI — esbuild transpiles TS without type-checking, so that's a real gap, left as a follow-up rather than growing this bootstrap PR with a new CI workflow step. Verified: nix build .#swarm-ui and .#frontend both succeed; npm run build (root, all workspaces) succeeds; tsc --noEmit clean; scripts/check-issue-refs.sh clean.
67 lines
2.6 KiB
Nix
67 lines
2.6 KiB
Nix
{
|
|
buildNpmPackage,
|
|
lib,
|
|
branding-svg,
|
|
}:
|
|
|
|
# Hermetic build of the npm-managed frontend workspaces (see
|
|
# `frontend/README.md`). Consumes `frontend/package-lock.json` as the
|
|
# source of truth for dependency versions; `npmDepsHash` pins the
|
|
# vendor-tarball hash so a stale lockfile fails the build instead of
|
|
# silently fetching different upstream tarballs.
|
|
#
|
|
# Output layout (`$out`) — two subdirectories, one per surface, that
|
|
# the Rust binaries serve via `tower_http::ServeDir`:
|
|
#
|
|
# $out/dashboard/ the hive-c0re dashboard assets (full layout in
|
|
# frontend/packages/dashboard/build.mjs):
|
|
# index.html (H0M3 hub, served at /) dashboard.html (operator SPA,
|
|
# served at /dashboard.html) flow.html logs.html settings.html
|
|
# stats.html favicon.svg
|
|
# static/{home,tabs,flow,logs,settings,stats,stream-worker}.js{,.map}
|
|
# static/{colors,theme,common,home,dashboard,flow,logs,settings,stats}.css
|
|
# $out/agent/ the per-agent default UI (layered with
|
|
# hyperhive.frontend.extraFiles at activation time)
|
|
# index.html stats.html screen.html
|
|
# static/{app,stats}.js{,.map}
|
|
# static/{colors,theme,agent}.css
|
|
#
|
|
# The dashboard favicon lives outside the npm tree (`branding/hyperhive
|
|
# .svg` at the repo root) — we copy it in during the install phase so
|
|
# the served prefix has everything in one place.
|
|
|
|
buildNpmPackage {
|
|
pname = "hyperhive-frontend";
|
|
version = "0.0.0";
|
|
src = ../../frontend;
|
|
|
|
# Computed from `frontend/package-lock.json` via
|
|
# prefetch-npm-deps frontend/package-lock.json
|
|
# Update whenever the lockfile changes. Recompute locally with the
|
|
# same command (`pkgs.prefetch-npm-deps`), or let the build fail
|
|
# and copy the actual hash from the error message.
|
|
npmDepsHash = "sha256-LIwW5Nn9cSqJHCm1czPIVxQdP5OqWk7U/4kvkwaj2ts=";
|
|
|
|
# `npm run build` recurses into all workspaces (`--workspaces
|
|
# --if-present`). The workspaces' build scripts each run their own
|
|
# `build.mjs` (esbuild).
|
|
npmBuildScript = "build";
|
|
|
|
# buildNpmPackage's default install phase copies the working dir into
|
|
# $out, which is overkill — we only want the dist trees. Hand-roll
|
|
# the install to keep $out tight.
|
|
dontNpmInstall = true;
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out/dashboard $out/agent
|
|
cp -r packages/dashboard/dist/. $out/dashboard/
|
|
cp -r packages/agent/dist/. $out/agent/
|
|
cp ${branding-svg} $out/dashboard/favicon.svg
|
|
runHook postInstall
|
|
'';
|
|
|
|
meta = {
|
|
description = "Bundled browser-facing assets for the hyperhive dashboard and per-agent UI";
|
|
homepage = "https://forge.darkest.space/hyperhive/hyperhive";
|
|
};
|
|
}
|