Enter the development shell:
nix developThis provides:
- Rust toolchain (rustc, cargo, rustfmt, clippy)
- cargo-watch, cargo-nextest, cargo-llvm-cov
- rust-analyzer for IDE support
- mold linker on Linux for faster builds
Build the entire project:
cargo build --workspaceOr use Nix:
nix build# Run all tests with nextest (faster, parallel)
cargo nextest run --workspace
# Run a specific test
cargo nextest run --workspace test_name
# Run tests in a specific crate
cargo nextest run -p harmonia-cache
# Watch mode during development
cargo watch -x 'nextest run --workspace'# Run unit/integration tests with coverage
nix build .#checks.x86_64-linux.tests -L
# Run NixOS VM tests (Linux only)
nix build .#checks.x86_64-linux.nix-daemon -L
nix build .#checks.x86_64-linux.harmonia-daemon -LCoverage reports are generated automatically in CI. To generate locally:
export LLVM_COV=$(which llvm-cov)
export LLVM_PROFDATA=$(which llvm-profdata)
cargo llvm-cov nextest --workspace --html
# Open target/llvm-cov/html/index.htmlRun the closure download benchmark:
cargo bench --package harmonia-bench
# With verbose output
cargo bench --package harmonia-bench -- --nocaptureThis benchmarks downloading a Python closure through harmonia-cache. By default it builds harmonia with the profiling profile (release + debug symbols for flamegraphs).
Environment variables:
HARMONIA_FLAKE- Use a nix-built harmonia instead of cargo buildBENCH_CLOSURE_FLAKE- Override the benchmark closure (default:.#bench-closure)
View results:
open target/criterion/closure/download/report/index.htmlFormat all code before committing:
nix fmtThis runs treefmt which handles:
- Rust: rustfmt (2024 edition)
- Nix: nixfmt
- C/C++: clang-format
# Clippy with warnings as errors
cargo clippy --all-targets --all-features -- -D warnings
# Or via Nix (same as CI)
nix build .#clippy -L- No
unsafecode (enforced via#![deny(unsafe_code)]workspace-wide) - Use
thiserrorfor error types - Use
tokiofor async runtime - Prefer
logmacros for logging
- Fork and create a feature branch
- Make your changes
- Ensure all checks pass:
nix fmt # Format code cargo clippy --all-targets --all-features -- -D warnings cargo nextest run --workspace - Write meaningful commit messages explaining why, not just what
- Open a PR against
master
PRs are tested by buildbot-nix which runs:
nix flake check(clippy, tests, NixOS VM tests)
CodeRabbit provides AI-powered code reviews on PRs. It automatically comments with suggestions for improvements, potential bugs, and style issues.
Codecov tracks test coverage. Coverage reports are uploaded automatically after successful builds. PRs show coverage changes inline.
Bencher tracks benchmark performance over time. Benchmarks run automatically when buildbot reports a successful build. Results are uploaded to detect performance regressions.
All checks must pass before merging.
The NixOS module is in module.nix. To test changes:
# Test with nix-daemon backend
nix build .#checks.x86_64-linux.nix-daemon -L
# Test with harmonia-daemon backend
nix build .#checks.x86_64-linux.harmonia-daemon -LOpen an issue at https://github.com/nix-community/harmonia/issues