This repository demonstrates "one-click" ways of cross building Rust code, deterministically. We use Nix to do the builds, and the artifacts are bit-for-bit reproducible. The examples also statically link against musl libc, because static linking is trickier to do, and because we can.
You need Docker for building the examples.
- This approach uses cross-rs/cross, managed by Nix, for the cross builds. It requires running a container engine (
podman) inside a Docker container, and privileged access permissions. Compared to the second approach, this one is less "pure" and conceptually more complex. Hence this approach is less preferred.
- This approach is "pure", in that it uses Nix to manage dependencies entirely.
- It demonstrates how to statically link to
opensslfor theunixtarget family. - It demonstrates cross builds on a
windowstarget (withoutopensslstatic linking, for simplicity).
In the directory root of the repository
makeOr for either approach
# Approach 1 make cross-rs # Approach 2 make rust-overlayClean up with command
make cleanOr for either approach
# Approach 1 make cr-clean # Approach 2 make ro-clean