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?
Make sure gcc is installed
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
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.