this post was submitted on 16 Mar 2024
6 points (100.0% liked)

Nix / NixOS

1465 readers
2 users here now

Main links

Videos

founded 1 year ago
MODERATORS
 

Hi! It's my first day with nixos. I tried to compile a rust project. To do so, I used a nix-shell with the content from here: https://nixos.wiki/wiki/Rust with the "Installation via rustup" option.

Unfortunately the compilation fails:

$ cargo check
   Compiling libc v0.2.151
   Compiling proc-macro2 v1.0.73
   Compiling serde v1.0.193
    Checking once_cell v1.19.0
   Compiling thiserror v1.0.53
error: linker `aarch64-linux-gnu-gcc` not found
  |
  = note: No such file or directory (os error 2)

error: could not compile `proc-macro2` (build script) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `serde` (build script) due to 1 previous error
error: could not compile `libc` (build script) due to 1 previous error
error: could not compile `thiserror` (build script) due to 1 previous error

I run NixOS 23.11 stable on a VM on a Macbook with M1 (arm64) CPU.

Any ideas how to fix that?

top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 5 points 5 months ago
[–] [email protected] 3 points 5 months ago

You might get better results with rust-overlay - that's what I've been using to cross-compile for aarch64-linux, and for compiling natively on Mac. Let me plug a guide I wrote, https://nixlang.wiki/en/nix/how-to/development-environment-for-rust#setting-a-fixed-rust-toolchain-version

[–] [email protected] 1 points 5 months ago

https://github.com/NixOS/nixpkgs/issues/145726

This might help, or at least point you in the right direction. Apologies but I have to post and run right now, I'll return and see if I can't help more asap.