Quick Comparison
Nix
Recommended
- Reproducible builds
- Matches CI environment
- Cross-platform support
- All tooling included
Bazel
Production
- Primary build system
- Remote execution ready
- Strict caching
- Advanced toolchains
Cargo
Development
- Standard Rust workflow
- Fast iteration
- IDE integration
- Direct dependencies
Prerequisites
Before building, ensure you have:- Git - For cloning the repository
- Build tools - C++ compiler (Clang recommended)
- Disk space - At least 10GB for build artifacts
Platform-Specific Requirements
- Linux
- macOS
- Windows
- Clang 11 or newer
- OpenSSL development headers
- pkg-config
Building with Nix
Nix provides the most reproducible builds and is the recommended method for development. It matches the CI environment closely.
Installation
Install Nix
Install Nix with flakes support using the experimental nix installer:
Install direnv (Recommended)
direnv automatically loads the development environment:Add the hook to your shell (see direnv hook documentation).After restarting your terminal:
Without direnv, run
nix develop manually each time you enter the repository.Building
Development Tools in Nix
The Nix development shell includes:- Bazel - Build system
- Rust - Stable toolchain with rust-analyzer
- Pre-commit - Git hooks for code quality
- git-cliff - Changelog generation
- Cloud Tools - AWS CLI, Google Cloud SDK, kubectl, etc.
- Debugging - dive, trivy for container inspection
flake.nix:453 for the complete tool list.
Building with Bazel
Bazel is NativeLink’s primary build system. It provides hermetic builds with strict dependency management.
Installation
Install Bazelisk
Bazelisk automatically manages Bazel versions:
Building
See Development with Bazel for advanced usage.Building with Cargo
Cargo provides the fastest iteration cycle for Rust development but requires manual dependency management.
Installation
Install Rust
Building
See Development with Cargo for advanced usage.Verifying Your Build
Test that your build works correctly:Build Artifacts
Nix Build Outputs
- Binary:
result/bin/nativelink - Docker Image:
result(loadable tarball) - Coverage:
result/index.html(from coverage builds)
Bazel Build Outputs
- Binary:
bazel-bin/nativelink - Documentation:
bazel-bin/*/doc/ - Test Results:
bazel-testlogs/
Cargo Build Outputs
- Debug:
target/debug/nativelink - Release:
target/release/nativelink - Documentation:
target/doc/ - Test Artifacts:
target/debug/deps/
Troubleshooting
Nix build fails with 'experimental features not enabled'
Nix build fails with 'experimental features not enabled'
Enable flakes in your Nix configuration:
Bazel fails with 'Cannot find C++ compiler'
Bazel fails with 'Cannot find C++ compiler'
Install Clang/LLVM:
Cargo fails with OpenSSL errors
Cargo fails with OpenSSL errors
Install OpenSSL development headers:
Out of disk space during build
Out of disk space during build
Clean build artifacts:
Next Steps
Development with Nix
Deep dive into Nix development workflow
Development with Bazel
Learn Bazel build system features
Development with Cargo
Master Cargo development workflow