Skip to content

fix(nix): include fastapi and build web frontend for dashboard#9307

Closed
lvnilesh wants to merge 1 commit into
NousResearch:mainfrom
lvnilesh:fix/nix-dashboard-packaging
Closed

fix(nix): include fastapi and build web frontend for dashboard#9307
lvnilesh wants to merge 1 commit into
NousResearch:mainfrom
lvnilesh:fix/nix-dashboard-packaging

Conversation

@lvnilesh

Copy link
Copy Markdown
Contributor

Summary

Fixes two Nix packaging bugs that break hermes dashboard:

  • fastapi missing from venv: uv2nix silently drops fastapi from 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 adding fastapi = []; to the mkVirtualEnv dependency set in nix/python.nix.

  • web_dist not built: The Vite/React frontend in web/ was never built during the Nix package build. The FastAPI server looks for web_dist adjacent to hermes_cli/web_server.py via Path(__file__).parent / "web_dist". Fixed by adding a buildNpmPackage derivation for the frontend, creating a site-packages overlay with web_dist symlinked into hermes_cli, and prepending it via PYTHONPATH in the wrapper scripts.

Fixes #9305

Test plan

  • nix build completes without errors
  • hermes dashboard starts the FastAPI server successfully
  • Web UI loads at http://127.0.0.1:9119 and serves the React SPA
  • python -c "import fastapi" works inside the wrapped environment

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings April 14, 2026 01:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Nix packaging so hermes dashboard can start its FastAPI backend and serve the built React/Vite frontend.

Changes:

  • Explicitly include fastapi in the uv2nix virtualenv dependency set.
  • Add a buildNpmPackage build for the web/ frontend and expose it to hermes_cli via a PYTHONPATH overlay 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.

Comment thread nix/packages.nix
# redirect into $out instead.
postPatch = ''
substituteInPlace vite.config.ts \
--replace-warn '../hermes_cli/web_dist' "$out"

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
--replace-warn '../hermes_cli/web_dist' "$out"
--replace-warn "\"../hermes_cli/web_dist\"" "\"$out\""

Copilot uses AI. Check for mistakes.
Comment thread nix/packages.nix
# 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)

Copilot AI Apr 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
venvSite=$(echo ${hermesVenv}/lib/python3.*/site-packages)
venvSite=${hermesVenv}/lib/python3.11/site-packages

Copilot uses AI. Check for mistakes.
chiyema added a commit to chiyema/hermes-agent that referenced this pull request Apr 14, 2026
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.
@lvnilesh lvnilesh deleted the fix/nix-dashboard-packaging branch April 21, 2026 23:14
@alt-glitch alt-glitch added type/bug Something isn't working area/nix Nix flake, NixOS module, container packaging comp/cli CLI entry point, hermes_cli/, setup wizard labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/nix Nix flake, NixOS module, container packaging comp/cli CLI entry point, hermes_cli/, setup wizard type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nix package: missing fastapi + web dashboard frontend not built

3 participants