Reproducible dev environment: Nix flake + just dev #38

Closed
resende wants to merge 2 commits from dev-environment into main
Collaborator

What

  • Nix flake dev shell (flake.nix / .envrc) pinning the full toolchain via flake.lock: stable rust (per rust-toolchain.toml) + rustfmt/clippy/rust-analyzer, clang+mold, node 22, pnpm 9, tmux, git, just. The shell is hermetic — it overrides the per-target linker/rustflags so it doesn't depend on (or break against) a personal ~/.cargo/config.toml (notably the nightly-only -Z threads=8).
  • just dev — runs the whole local stack (registry :8080 + daemon :7070 + Vite UI :5173) in one command, health-gated, with Ctrl-C teardown. Previously the Justfile only had frontend/CI recipes.
  • Vite attach fix — /api/attach/:id is a daemon-served broker WebSocket (NAP-243), not a registry route, so the catch-all /api proxy sent it to the registry → 404. Now routed to the daemon (overridable via MAESTRO_DAEMON), the same split the production maestro-web binary does.

Verified

  • cargo build --workspace --all-targets, cargo clippy, and the full web build all pass inside nix develop.
  • Full stack boots via just dev; the attach handshake returns 101 and PTY bytes stream; Ctrl-C leaves no stray processes.

🤖 Generated with Claude Code

## What - **Nix flake dev shell** (`flake.nix` / `.envrc`) pinning the full toolchain via `flake.lock`: stable rust (per `rust-toolchain.toml`) + rustfmt/clippy/rust-analyzer, clang+mold, node 22, pnpm 9, tmux, git, just. The shell is hermetic — it overrides the per-target linker/rustflags so it doesn't depend on (or break against) a personal `~/.cargo/config.toml` (notably the nightly-only `-Z threads=8`). - **`just dev`** — runs the whole local stack (registry :8080 + daemon :7070 + Vite UI :5173) in one command, health-gated, with Ctrl-C teardown. Previously the Justfile only had frontend/CI recipes. - **Vite attach fix** — `/api/attach/:id` is a daemon-served broker WebSocket (NAP-243), not a registry route, so the catch-all `/api` proxy sent it to the registry → 404. Now routed to the daemon (overridable via `MAESTRO_DAEMON`), the same split the production `maestro-web` binary does. ## Verified - `cargo build --workspace --all-targets`, `cargo clippy`, and the full web build all pass inside `nix develop`. - Full stack boots via `just dev`; the attach handshake returns `101` and PTY bytes stream; Ctrl-C leaves no stray processes. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
resende added 2 commits 2026-06-23 13:27:51 +01:00
The repo shipped no committed dev environment, so building required a
working personal Nix/home-manager setup on PATH. Add a flake providing
the full toolchain pinned via flake.lock: stable rust (per
rust-toolchain.toml) + rustfmt/clippy/rust-analyzer, clang + mold
(the linker the cargo config expects), nodejs 22, pnpm 9, tmux, git,
and just.

The shell sets the per-target linker/rustflags so it is self-contained
and hermetic: cargo takes the first matching rustflags source (env >
target > build), so this replaces any global `[build] rustflags` — in
particular the nightly-only `-Z threads=8` that would otherwise break
the stable toolchain — while keeping the fast mold link.

Use with `nix develop` or `direnv allow` (.envrc).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`just dev` builds maestro and runs the whole local stack in one command
— registry (:8080), daemon (:7070), and the Vite web UI (:5173) — waits
for each to be healthy, and tears all three down on Ctrl-C. Previously
the Justfile only had frontend/CI recipes; running the project meant
hand-starting the registry and daemon in separate terminals.

Also fix attach under the Vite dev server: `/api/attach/:id` is a
daemon-served broker WebSocket (NAP-243), not a registry route, so the
old catch-all `/api` proxy sent it to the registry and got 404. Route
`/api/attach` to the daemon (overridable via MAESTRO_DAEMON) and keep
everything else on the registry — the same split the production
maestro-web binary does. Verified: handshake now returns 101 and PTY
bytes stream.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator

Closing — superseded. Opening a replacement that keeps the one part of this that still holds.

401afbc landed a flake-parts + crane flake with packages.maestro, packages.maestro-web, packages.webFrontend, checks (fmt/clippy/build), and a devShells.default built from craneLib.devShell. That covers this PR's dev shell and then some.

The other two pieces no longer apply:

  • just dev starts a registry on :8080, but d006f4a removed the registry from the daemon core. Two thirds of the recipe has nothing to start.
  • The Vite proxy split is already solved differently: web/vite.config.ts has a single /api proxy with ws: true pointed at the daemon on 127.0.0.1:7070, overridable via MAESTRO_DAEMON_URL, which covers /api/attach/:id along with everything else.

What does survive is the diagnosis in the last bullet of the description: a personal ~/.cargo/config.toml pointing the linker at clang+mold breaks a build in a shell that ships neither. That reproduces today — cargo build inside the dev stack failed with error: linker 'clang' not found until clang and mold were added.

The replacement adds a process-compose stack (nix run .#dev) to the existing flake instead of a bash recipe in the Justfile, so dependency ordering and readiness are declared rather than hand-rolled with /dev/tcp polling. It also picks up the .envrc from here.

Closing — superseded. Opening a replacement that keeps the one part of this that still holds. `401afbc` landed a flake-parts + crane flake with `packages.maestro`, `packages.maestro-web`, `packages.webFrontend`, `checks` (fmt/clippy/build), and a `devShells.default` built from `craneLib.devShell`. That covers this PR's dev shell and then some. The other two pieces no longer apply: - `just dev` starts a registry on :8080, but `d006f4a` removed the registry from the daemon core. Two thirds of the recipe has nothing to start. - The Vite proxy split is already solved differently: `web/vite.config.ts` has a single `/api` proxy with `ws: true` pointed at the daemon on 127.0.0.1:7070, overridable via `MAESTRO_DAEMON_URL`, which covers `/api/attach/:id` along with everything else. What does survive is the diagnosis in the last bullet of the description: a personal `~/.cargo/config.toml` pointing the linker at clang+mold breaks a build in a shell that ships neither. That reproduces today — `cargo build` inside the dev stack failed with `error: linker 'clang' not found` until clang and mold were added. The replacement adds a `process-compose` stack (`nix run .#dev`) to the existing flake instead of a bash recipe in the Justfile, so dependency ordering and readiness are declared rather than hand-rolled with `/dev/tcp` polling. It also picks up the `.envrc` from here.
naps62-yolo closed this pull request 2026-08-22 19:46:07 +01:00
This repo is archived. You cannot comment on pull requests.