Skip to content

Development setup

Get from a fresh clone to a running local stack. For multi-node clusters on your machine, see Local clusters; for test suites, see Testing.

Enter the Nix dev shell (or run direnv allow—.envrc runs use flake):

Terminal window
nix develop
pnpm install # web UI, agents sidecar, and sites share one pnpm workspace

The dev shell provides rustup (pinned by rust-toolchain.toml), just, cargo-nextest, sqlx-cli, Node 24, pnpm, PostgreSQL 17, oasdiff, cargo-zigbuild + Zig (static Linux builds for local clusters), llvm-objcopy, and vde_switch (for the VM cluster network), and points DATABASE_URL at .data/pg.

Run the UI from your checkout with HMR while sending API calls to a real cluster you’re already enrolled in:

Terminal window
just dev personal # omit `personal` to use ANASTRO_CONTEXT or your default context

just dev builds anastroctl, starts Vite on a private port, and opens a single-use sign-in link on a shared authenticated loopback origin (open that link rather than Vite’s raw port). Because API calls travel over iroh as your enrolled device, actions touch real projects and machines—no local Postgres or daemon needed. Press Ctrl-C to stop.

For the native desktop app, install tauri-cli once and run:

Terminal window
cargo install tauri-cli --locked
just dev-app personal

This launches Anastro Dev with its own app ID so your installed Anastro app stays untouched, with HMR for React/CSS and automatic Rust rebuilds for desktop and shared CLI/transport crates.

Useful variants:

Terminal window
just dev personal --listen 127.0.0.1:7482 --no-open # fixed port, print link
cargo run -p anastroctl -- --context personal ui --dev-url http://127.0.0.1:5173 # attach to existing Vite
just cli # rebuild and install anastroctl to ~/.local/bin
just app # rebuild and restart the macOS app in ~/Applications
just local # both

Clone Anastro to /workspace/anastro inside a running machine, enter its dev shell, run pnpm install, and launch the dev companion from your signed-in computer:

Terminal window
just dev-machine <machine> personal
# Or with a custom checkout path:
just dev-machine <machine> personal /workspace/my-checkout

The companion starts Vite inside the machine and prints a loopback URL to open in that machine’s Browser tab (or ask the agent to open it with browser_open). API requests, streams, and WebSockets tunnel over your terminal session using your computer’s enrolled device—no device key or cookie ever enters the guest, and no firewall change is needed.

Press Ctrl-C to close the dev server and tunnel (if the companion disconnects, the guest shuts it down after ~20 seconds). This workflow targets the cluster’s deployed API; Rust API or sidecar changes still need a local stack or cluster deployment.

On a computer that can reach your cluster over iroh, run anastroctl account device id (or anastroctl login to print a join string and wait), then approve it from an already-enrolled machine:

Terminal window
cargo run -p anastroctl -- --context personal account device approve <endpoint-id-or-join-string> --name anastro-dev

Pass --expires-in-days 1 for a temporary dev device. If the new machine doesn’t have a client file yet, generate a sign-in link with anastroctl account device link and run anastroctl login --enroll '<link>' there instead.

Start each service in its own terminal:

Command Starts
just apid Local Postgres in .data/pg + apid on 127.0.0.1:7443 (API docs at /api/docs; .data/iroh/bootstrap-admin becomes first admin if present)
just machined Node iroh endpoint on 127.0.0.1:7444 forwarding to apid (--iroh-allow-any)
just schedd Scheduler and reconcilers (placement, idle spin-down, workspace GC)
just web Vite on http://localhost:5173 proxying /v1, /api, and /healthz to apid (override with ANASTRO_API)
just agents Agents sidecar on 127.0.0.1:7445 with live reload

Database helpers: just db-up, just db-down, and just db-reset. SQL migrations live in crates/db/migrations and run automatically when apid boots.

Validate a config repo using anastroctl from source:

Terminal window
cargo run -p anastroctl -- -C examples/prod cluster validate

OpenAPI specs, Cedar policies, config JSON Schemas, and TypeScript API clients are all generated from Rust code. Whenever you change an API or config type, regenerate and commit them (CI fails on drift):

Terminal window
just codegen

After changing CLI flags or config fields, also regenerate the docs reference pages:

Terminal window
cargo build -p anastroctl
pnpm --filter @anastro/docs gen:cli
pnpm --filter @anastro/docs gen:config
Terminal window
just check

Runs the full CI gate locally: RustSec/cargo-deny, desktop workspace compile, cargo fmt --check, clippy -D warnings, cargo xtask codegen --check, cargo test --workspace, and web/sidecar typechecks and tests. Format Rust with just fmt. Check the sites with pnpm check at the repo root.

Directory Site Dev command
sites/docs Documentation (docs.anastro.dev, Astro + Starlight) pnpm dev:docs
sites/landing Landing page (Vite) pnpm dev:landing
sites/brand Shared tokens.css and SVG marks —

Run pnpm build at the repo root to build everything, or pnpm --filter './sites/*' build for just the sites. Docs writing guidelines live in sites/docs/STYLE.md.

crates/ Rust workspace (see below)
web/ Web UI (Vite, React 19, TanStack Router & Query, Tailwind v4)
agents/ Pi Durable sidecar (Node, Hono + zod-openapi)
desktop/ Tauri desktop and iOS apps
api/openapi/ Generated OpenAPI 3.1 specs
api/policies/ Generated Cedar schemas and policies (from OpenAPI x-roles)
schema/ Generated JSON Schemas for anastro.toml and node files
examples/ Sample config repos (single-node and 3-node prod)
docs/spec.md Full design spec
sites/ Docs site, landing page, and shared brand assets
nix/
package.nix anastrod and anastroctl (`ctl` output)
web.nix Embedded web UI Nix build
agents.nix Agents sidecar Nix build
secureboot-*.nix Key generation and local out-of-store signing tools
modules/ Node OS image (anastro.nix, image.nix, slim.nix)
cluster.nix Multi-node QEMU VM cluster launcher
clusters/ Config repos for local VM clusters (single, ha)
tests/ NixOS VM test suites (single, ha, iso)
dev/ Dev cluster scripts, dev keys, and VM overlays
guest/ Linux microVM guest image, kernel, and KVM test lane
kvm-e2e/ Full KVM end-to-end lane and Linux-only test runner
kvm-cluster/ Local 3-node KVM container cluster
Crate Purpose
anastrod Multi-call daemon binary (apid, machined, schedd, secretd, keyd, opd, relay, hostagent, dwfsd)
anastroctl User and operator CLI
api Axum routers + utoipa annotations, Cedar auth gate, and machined node logic (src/node)
api-types Shared API request/response types
config anastro.toml + node file parsing, merging, validation, apply diffs, and JSON Schema
db Shared Postgres pool and SQL migrations
iroh-transport HTTP/1.1 over iroh streams, apid forwarding, peer allowlisting, and built-in relay
secretd Cluster secret store (in-memory KEK, envelope encryption, Unix socket)
keyd Built-in DWFS workspace key provider
scheduler Machine placement and background reconcilers (schedd)
hostagent Cloud Hypervisor microVM runner (networking, disks, live moves, secrets, git broker)
guest anastro-guest PID 1 inside microVMs (commands and terminals over vsock)
agent-proto Wire protocol between control plane, hostagent, and anastro-guest
fakehost In-process mock host agent for deterministic API/scheduler tests
dwfs-engine Runner-side core of the snapshotted workspace filesystem
dwfs-control DWFS control plane (catalog, leases, head CAS, locations, GC, repacking)
dwfs-frontends Kernel mounts: FUSE on Linux (via virtiofsd), NFSv3 on macOS
dwfsd Per-host DWFS daemon on Linux workers
objstore S3/R2/Garage/local object stores, scoped host credentials, probes, and migration
inference Model accounts, gateway tokens, Codex/Claude/Antigravity logins, and token metering
integrations GitHub App, 1Password resolver (opd), remote MCP connectors, and credential sealing
agents-client Build-time generated Rust client for api/openapi/agents.json
telemetry Logging and OTLP setup
xtask cargo xtask codegen [--check]
netwatch Vendored netwatch 0.19.3 with one rebind-retry patch for iroh