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.
58 lines
2.3 KiB
Nix
58 lines
2.3 KiB
Nix
{ buildNpmPackage }:
|
|
|
|
# Static build of the swarm-level UI shell (project-bootstrap scope:
|
|
# empty start page, no functionality yet — see
|
|
# frontend/packages/swarm-ui/package.json for the full rationale).
|
|
# Stack: Preact + wouter + TypeScript + JSX, a real SPA shell with
|
|
# routing/deep-links, distinct from the per-hive dashboard's
|
|
# vanilla-JS + custom-element MPA.
|
|
#
|
|
# Deliberately its OWN package, not folded into `./frontend.nix`
|
|
# (which bundles dashboard + agent into `packages.default`'s closure):
|
|
# swarm-ui is swarm-scoped, 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 in its closure.
|
|
#
|
|
# Not yet consumed anywhere: swarm-controller only serves `/health`
|
|
# today (swarm-controller/README.md) — this just makes the static
|
|
# build a buildable, packageable artifact so the wiring (once auth
|
|
# against authelia is figured out) has something to point at.
|
|
#
|
|
# Shares `frontend/package-lock.json` with `./frontend.nix` (same repo,
|
|
# same npm workspace root) — `npmDepsHash` must be updated in lockstep
|
|
# with that file's whenever the lockfile changes, since both hash the
|
|
# same file. Scoped to build only the `swarm-ui` workspace (not the
|
|
# whole `npm run build --workspaces` frontend.nix runs) via an explicit
|
|
# `npm run build --workspace=…` buildPhase, so a dashboard/agent-only
|
|
# change doesn't need to rebuild (or re-review the output of) this
|
|
# derivation.
|
|
|
|
buildNpmPackage {
|
|
pname = "hyperhive-swarm-ui";
|
|
version = "0.0.0";
|
|
src = ../../frontend;
|
|
|
|
# Recompute with `prefetch-npm-deps frontend/package-lock.json`
|
|
# whenever the lockfile changes — same value as `./frontend.nix`'s
|
|
# `npmDepsHash`, both hash the one shared lockfile.
|
|
npmDepsHash = "sha256-LIwW5Nn9cSqJHCm1czPIVxQdP5OqWk7U/4kvkwaj2ts=";
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
npm run build --workspace=packages/swarm-ui
|
|
runHook postBuild
|
|
'';
|
|
|
|
dontNpmInstall = true;
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out
|
|
cp -r packages/swarm-ui/dist/. $out/
|
|
runHook postInstall
|
|
'';
|
|
|
|
meta = {
|
|
description = "hyperhive swarm-level UI static frontend build (bootstrap — empty start page)";
|
|
homepage = "https://forge.darkest.space/hyperhive/hyperhive";
|
|
};
|
|
}
|