fix(nix): include fastapi and build web frontend for dashboard#9307
fix(nix): include fastapi and build web frontend for dashboard#9307lvnilesh wants to merge 1 commit into
Conversation
Two bugs prevented `hermes dashboard` from working in the Nix package: 1. uv2nix silently drops fastapi from the virtualenv even though the [web] extra requires it. Explicitly add fastapi to the mkVirtualEnv dependency set so it is always present. 2. The web frontend (Vite/React app in web/) was never built during the Nix build. Add a buildNpmPackage derivation for the frontend, create a site-packages overlay that places web_dist alongside hermes_cli, and prepend it via PYTHONPATH in the wrapper scripts. Fixes NousResearch#9305 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes Nix packaging so hermes dashboard can start its FastAPI backend and serve the built React/Vite frontend.
Changes:
- Explicitly include
fastapiin the uv2nix virtualenv dependency set. - Add a
buildNpmPackagebuild for theweb/frontend and expose it tohermes_clivia aPYTHONPATHoverlay in wrapped executables.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
nix/python.nix |
Forces fastapi into the virtualenv to avoid uv2nix dropping it. |
nix/packages.nix |
Builds the web frontend with Nix and injects web_dist via a site-packages overlay + wrapper PYTHONPATH. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # redirect into $out instead. | ||
| postPatch = '' | ||
| substituteInPlace vite.config.ts \ | ||
| --replace-warn '../hermes_cli/web_dist' "$out" |
There was a problem hiding this comment.
substituteInPlace is replacing a single-quoted string ('../hermes_cli/web_dist'), but web/vite.config.ts currently uses double quotes ("../hermes_cli/web_dist"). As a result the patch won’t apply and the Vite build will still write outside $out, likely leaving the hermesWeb derivation empty and web_dist missing at runtime. Update the substitution to match the actual string (or patch vite.config.ts more robustly).
| --replace-warn '../hermes_cli/web_dist' "$out" | |
| --replace-warn "\"../hermes_cli/web_dist\"" "\"$out\"" |
| # Create a thin overlay directory that shadows hermes_cli with web_dist | ||
| # present, then prepend it via PYTHONPATH so Python finds it first. | ||
| hermesSiteOverlay = pkgs.runCommand "hermes-site-overlay" { } '' | ||
| venvSite=$(echo ${hermesVenv}/lib/python3.*/site-packages) |
There was a problem hiding this comment.
venvSite=$(echo ${hermesVenv}/lib/python3.*/site-packages) relies on a wildcard/glob expansion. If multiple matches ever exist (or the glob fails to expand), this can produce an invalid path list and break the overlay build. Since this venv is pinned to Python 3.11, prefer using the exact path (e.g., ${hermesVenv}/lib/python3.11/site-packages) or compute it deterministically in a way that guarantees a single directory.
| venvSite=$(echo ${hermesVenv}/lib/python3.*/site-packages) | |
| venvSite=${hermesVenv}/lib/python3.11/site-packages |
Two issues prevented 'hermes dashboard' from working in the Nix package: 1. uv.lock was missing the [web] extra — fastapi and uvicorn were only resolved under the [rl] marker, so the [all] extra didn't include them. Regenerated with 'uv lock' to fix the root cause. 2. nix/packages.nix didn't build or bundle the Vite/React frontend. Added buildNpmPackage derivation for the frontend and a site-packages overlay with web_dist symlinked into hermes_cli, prepended via PYTHONPATH in the wrapper scripts. No application code changes needed. Tested on x86_64-linux (NixOS Proxmox LXC): - nix build succeeds with fastapi 0.133.1 and uvicorn 0.41.0 in the venv - web_dist is built and symlinked into the hermes_cli overlay - 'hermes dashboard --host 0.0.0.0 --port 9119 --no-open' starts successfully as a systemd service, returns HTTP 200, and serves the React frontend on LAN See also NousResearch#9307 for an alternative approach.
Summary
Fixes two Nix packaging bugs that break
hermes dashboard:fastapi missing from venv: uv2nix silently drops
fastapifrom the virtualenv even though the[web]extra requires it (its transitive deps like starlette/uvicorn are present, but fastapi itself is not). Fixed by explicitly addingfastapi = [];to themkVirtualEnvdependency set innix/python.nix.web_dist not built: The Vite/React frontend in
web/was never built during the Nix package build. The FastAPI server looks forweb_distadjacent tohermes_cli/web_server.pyviaPath(__file__).parent / "web_dist". Fixed by adding abuildNpmPackagederivation for the frontend, creating a site-packages overlay withweb_distsymlinked intohermes_cli, and prepending it viaPYTHONPATHin the wrapper scripts.Fixes #9305
Test plan
nix buildcompletes without errorshermes dashboardstarts the FastAPI server successfullypython -c "import fastapi"works inside the wrapped environment🤖 Generated with Claude Code