The hash was hardcoded independently in nix/packages/frontend.nix, nix/packages/swarm-ui.nix, and nix/checks.nix's inline swarm-ui-typecheck derivation, all three building from the one frontend/package-lock.json. Nothing enforced the three copies staying in sync, and on a recent PR only some of them got updated when the lockfile changed. Moved the hash into a new file, frontend/npm-deps-hash (plain text, no trailing newline, co-located with package-lock.json so it reads as the lockfile's other half), and all three derivations now builtins.readFile it instead of hardcoding their own copy. A lockfile change now only needs prefetch-npm-deps + one file overwrite; the other two derivations pick it up automatically. Verified: nix eval against all three derivations' npmDepsHash attribute (eval-only, not a build) confirms all three resolve to the same value read from the one file.
59 lines
2.3 KiB
Nix
59 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` is read from
|
|
# `../../frontend/npm-deps-hash`, the same file `./frontend.nix` and
|
|
# `../checks.nix`'s `swarm-ui-typecheck` read, so all three stay in
|
|
# lockstep automatically instead of needing 3 separate hand-edits.
|
|
# 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;
|
|
|
|
# See `./frontend.nix`'s comment on the same line — one shared file,
|
|
# regenerate with `prefetch-npm-deps frontend/package-lock.json`.
|
|
npmDepsHash = builtins.readFile ../../frontend/npm-deps-hash;
|
|
|
|
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";
|
|
};
|
|
}
|