Building from Source

March 9, 2026 ยท View on GitHub

Dependencies

  • Rust 1.88.0+ (install via rustup)

Using Cargo

# Debug build
cargo build

# Release build (optimized for size: opt-level=z, LTO, strip)
cargo build --release

# Build all workspace members with all features
cargo build --all-features --workspace

# Build a specific crate
cargo build -p distant-core
cargo build -p distant-docker
cargo build -p distant-host
cargo build -p distant-ssh

# Install the binary locally from source
cargo install --path .

Using Nix

If you have Nix with flakes enabled, you can build without manually installing Rust or any native dependencies:

# Build the release binary
nix build

# The binary will be at ./result/bin/distant

# Enter a development shell with all tools available
nix develop

Completely static binary

To compile a completely static binary (not linked to libc), target musl:

rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl

Mac-specific

On macOS you will need to install musl-gcc:

brew install FiloSottile/musl-cross/musl-cross

And to strip (on Mac), use the musl strip:

x86_64-linux-musl-strip target/x86_64-unknown-linux-musl/release/distant

Cross-compilation

The CI release workflow builds for the following targets:

PlatformTargetNotes
macOSx86_64-apple-darwin
macOSaarch64-apple-darwin
macOSUniversal binarylipo merge of both architectures
Windowsx86_64-pc-windows-msvc
Windowsaarch64-pc-windows-msvc
Linuxx86_64-unknown-linux-gnu
Linuxaarch64-unknown-linux-gnuNeeds gcc-aarch64-linux-gnu
Linuxarmv7-unknown-linux-gnueabihfNeeds gcc-arm-linux-gnueabihf
Linux (musl)x86_64-unknown-linux-muslNeeds musl-tools
Linux (musl)aarch64-unknown-linux-muslUses cross
FreeBSDx86_64-unknown-freebsdUses cross