Rust: Difference between revisions

m Add usage example for cargo-xwin
Kiri (talk | contribs)
m Format table so the header is clearly distinguished from the rest of the rows.
 
(3 intermediate revisions by 3 users not shown)
Line 37: Line 37:


== Installating with bindgen support ==
== Installating with bindgen support ==
By default crates using <code>bindgen</code> will not compile. To add bindegen support add the <code>rustPlatform.bindegenHook</code> to your <code>nativeBuildInputs</code>.
By default crates using <code>bindgen</code> will not compile. To add bindgen support add the <code>rustPlatform.bindgenHook</code> to your <code>nativeBuildInputs</code>.


Here's an example <code>shell.nix</code>:
Here's an example <code>shell.nix</code>:
Line 152: Line 152:


* use [https://crates.io/crates/cargo-xwin cargo-xwin] with rustup install or the [https://search.nixos.org/packages?show=cargo-xwin&type=packages&query=cargo+windows nix cargo plugin]  
* use [https://crates.io/crates/cargo-xwin cargo-xwin] with rustup install or the [https://search.nixos.org/packages?show=cargo-xwin&type=packages&query=cargo+windows nix cargo plugin]  
* run cargo commands prefixed by xwin, e.g. <code>cargo xwin run</code>  
* run cargo commands prefixed by xwin, e.g. <code>cargo xwin run --target x86_64-pc-windows-msvc</code>


== Unofficial overlays ==
== Unofficial overlays ==
Line 227: Line 227:
At the time of writing, there are now no less than 8 different solutions for building Rust code with Nix. In the following table they are compared:
At the time of writing, there are now no less than 8 different solutions for building Rust code with Nix. In the following table they are compared:


{|
{| class="wikitable" style="margin:auto"
| Name
| Cargo.lock solution
| Derivations
| Build logic
| Supports cross
| Notes
|-
|-
| [https://github.com/NixOS/nixpkgs/blob/4fc53b59aecbc25c0e173163d60155f8fca14bfd/doc/languages-frameworks/rust.section.md <code>buildRustPackage</code>]
! Name !! Cargo.lock solution !! Derivations !! Build logic !! Supports cross !! Notes
|-
| <code>[https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks/rust.section.md buildRustPackage]</code>
| Checksum
| Checksum
| 1
| 1