this post was submitted on 16 Mar 2024
5 points (85.7% liked)

Nix / NixOS

1725 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?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 3 points 7 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