Files
nexu-io-open-design/nix/package-web.nix
PerishFire 891981d460 [codex] Optimize CI runtime topology (#4450)
* Optimize e2e tools-dev runtime parallelism

* Remove visual networkidle wait

* Optimize e2e vitest parallelism

* Optimize Nix flake caching

* Test CI on Blacksmith runners

* Allow parallel manual CI runs

* Tier CI runner sizes

* Temporarily narrow CI debug scope

* Instrument watcher CI timeouts

* Instrument watcher event diagnostics

* Avoid default polling in watcher tests

* Skip runtime trace during watcher debug

* Probe ARM runner tiers for CI

* Focus CI runner probe on x64 browser

* Probe browser workers by runner size

* Probe Playwright file parallelism

* Probe Playwright worker scaling on 8v

* Reshape CI topology

* Fix split E2E Vitest CI lane

* Simplify daemon CI topology

* Optimize Windows payload CI setup

* Revert "Optimize Windows payload CI setup"

This reverts commit 5cbc48c0af.

* Cache better-sqlite3 Nix binding separately

* Revert "Cache better-sqlite3 Nix binding separately"

This reverts commit 0384e3787e.

* Remove unused Nix cache setup from CI

* Use Blacksmith ARM for lightweight CI jobs
2026-06-17 12:53:06 +08:00

94 lines
2.5 KiB
Nix

{
lib,
stdenv,
dream2nix,
nixpkgs,
system,
nodejs,
pnpm_10,
fetchPnpmDeps,
pnpmConfigHook,
src,
pnpmDepsSrc ? src,
workspacePaths,
}:
# Builds the @open-design/web Next.js static export.
#
# Output layout: $out/ contains the contents of `apps/web/out/` (an
# index.html plus _next/ and asset subdirectories). Drop $out into any
# static file server.
#
# OD_DAEMON_URL is set to "" at build time so the bundled JS issues
# relative requests (`/api/*`, `/artifacts/*`, `/frames/*`) instead of
# baking a build-time daemon URL into the export. The serving
# environment is therefore expected to be same-origin with the daemon —
# the bundled caddy in the modules reverse-proxies those paths to
# `127.0.0.1:<cfg.port>`, and a custom nginx/caddy must do the same.
let
pname = "open-design-web";
version = (lib.importJSON ../package.json).version;
pnpmDepsHash = (import ./pnpm-deps.nix).webHash;
pnpmWorkspaceFilters = map (workspacePath: "./${workspacePath}") workspacePaths;
dependencyBuildPaths = lib.filter (workspacePath: workspacePath != "apps/web") workspacePaths;
in
stdenv.mkDerivation (finalAttrs: {
inherit pname version src;
pnpmWorkspaces = pnpmWorkspaceFilters;
nativeBuildInputs = [
nodejs
pnpm_10
pnpmConfigHook
];
pnpmDeps = fetchPnpmDeps {
inherit (finalAttrs) pname version;
src = pnpmDepsSrc;
hash = pnpmDepsHash;
# Force the deps-fetch derivation to use the flake's pinned
# pnpm_10 as well. fetchPnpmDeps defaults to `pkgs.pnpm` when
# the `pnpm` arg is omitted.
pnpm = pnpm_10;
pnpmWorkspaces = pnpmWorkspaceFilters;
fetcherVersion = 3;
};
env = {
NODE_ENV = "production";
OD_DAEMON_URL = "";
};
buildPhase = ''
runHook preBuild
for target in ${lib.escapeShellArgs dependencyBuildPaths}; do
pnpm -C "$target" run --if-present build
done
# next.config.ts gates static-export emission on NODE_ENV=production
# and writes to apps/web/out/.
pnpm --filter @open-design/web run build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r apps/web/out/. $out/
runHook postInstall
'';
passthru = {
inherit nodejs;
pnpmDeps = finalAttrs.pnpmDeps;
};
meta = with lib; {
description = "Open Design Next.js static SPA (apps/web)";
homepage = "https://github.com/nexu-io/open-design";
license = licenses.asl20;
platforms = platforms.linux ++ platforms.darwin;
};
})