oxalica / rust-overlay

Pure and reproducible nix overlay of binary distributed rust toolchains
MIT License
960 stars 57 forks source link

Add flake examples for cross-compilation #163

Closed holly-hacker closed 6 months ago

holly-hacker commented 8 months ago

For the past hour I've been trying to convert the cross-aarch64 example to a flake, to no avail. It'd be nice if an example of this was provided.

oxalica commented 6 months ago

cross-aarch64 example to a flake

I don't think the current flake design supports cross-compilation without re-importing nixpkgs with a custom config, which also opt-out flake benefits like eval-caching. There are issues https://github.com/NixOS/nix/issues/5157 and blogs about the current state of cross-compilation for flakes.

Alternatively to the re-importing with config/overlay solution, we can also provide a builder interface for rust-overlay to be used as (rust-overlay.lib.mkRustBin nixpkgs.legacyPackages.pkgsCross.aarch64-multiplatform).stable.latest. This will re-instantiate only rust-overlay packages rather than all nixpkgs packages. It still cannot use eval-cache and will instantiate every time for each flake input using rust-overlay, but at least it's the lesser of two evils.

The second solution is also mentioned in https://github.com/oxalica/rust-overlay/issues/94#issuecomment-2071471458

holly-hacker commented 6 months ago

Thanks for the fix!