Prerequisites
Before you begin, make sure you have the following installed:- Git - to clone the repository
- Nix - Malbox uses a Nix flake for reproducible development environments. Install Nix with flakes enabled via the Determinate Systems installer or the official installer
- A Linux host (or WSL2 on Windows)
Clone and enter the environment
- Rust stable toolchain (rustc, cargo, clippy, rustfmt, rust-analyzer)
- PostgreSQL 16
- Node.js and pnpm
- C/C++ build tools (cmake, gcc, clang 18)
- Windows cross-compilation toolchain (MinGW)
- Infrastructure tools (packer, ansible)
- Protobuf compiler and codegen tools
- Pre-commit hooks (cargo-check, clippy, rustfmt)
The first run takes a while as Nix downloads and builds all dependencies. Subsequent runs are near-instant.
back-end/, front-end/, docs/) includes an .envrc file that activates the appropriate sub-shell automatically. If you use direnv, just cd into the directory you want to work in.
Database
process-compose manages PostgreSQL 16. Start it from theback-end/ directory:
malbox_db database automatically.
The DATABASE_URL environment variable is set for you automatically by the flake:
| Setting | Value |
|---|---|
| Host | 127.0.0.1 |
| Port | 5432 |
| Database | malbox_db |
| User | postgres |
| DATABASE_URL | postgres://postgres@localhost:5432/malbox_db |
Running the backend
Make sure PostgreSQL is running viaprocess-compose up first (see Database), then from the back-end/ directory:
http://127.0.0.1:8080.
Running the frontend
In a separate terminal:http://localhost:5173. It proxies API requests to the backend at the URL configured in .env:
Running the docs
In a separate terminal:http://localhost:3000.
Daily workflow
Running tests
Formatting and linting
Pre-commit hooks run cargo-check, clippy, and rustfmt automatically on every commit. You can also run them manually:Type checking the frontend
Database migrations
Create a new migration:Building Rust documentation
Pre-commit hooks
The Nix flake installs Git hooks that run on every commit:- cargo-check - verifies the project compiles
- clippy - catches common mistakes and style issues
- rustfmt - enforces consistent formatting
--no-verify. If a hook fails, fix the issue before committing.
Troubleshooting
nix develop fails or hangs
Make sure Nix is installed correctly and the Nix daemon is running:
Database connection refused
PostgreSQL may not be running. Check its status:process-compose up is running in the back-end/ directory (see Database).
SQLx compile errors about missing queries in CI
If you see SQLx compile-time errors, make sure the offline query cache is up to date:SQLX_OFFLINE=true:
Frontend can’t reach the backend
Make sure:- PostgreSQL is running (
process-compose upinback-end/) - The backend is running (
cargo run -p malbox -- daemon start) - Your
.envfile has the correctMALBOX_API_URL(default:http://127.0.0.1:8080)