Open StealthyKamereon opened 4 months ago
For those who can't wait a fix, I found a dirty workaround. Make a directory in your project and create a auxiliary nix store by copying the rust package :
# Set the RUST_PKG with the shell.nix. For example, my RUST_PKG contains the following:
export RUST_PKG=/nix/store/v0769idpz76l6b3xff8ps98bcsy5ymjb-rust-default-1.80.0-nightly-2024-05-20
nix copy --to /<project-dir>/local-store $RUST_PKG --no-check-sigs
This will take care of copying all the necessary packages.
Then simply enable writing in the local store:
chmod u+w -R /<project-dir>/local-store
You then need to tell your lsp where your sysroot is. For example, I have these settings for vscode:
{
"rust-analyzer.server.path": "/<project-dir>/local-store/nix/store/v0769idpz76l6b3xff8ps98bcsy5ymjb-rust-default-1.80.0-nightly-2024-05-20/bin/rust-analyzer",
"rust-analyzer.cargo.sysroot": "/<project-dir>/local-store/nix/store/v0769idpz76l6b3xff8ps98bcsy5ymjb-rust-default-1.80.0-nightly-2024-05-20/",
"rust-analyzer.rustc.source": "discover"
}
HI @StealthyKamereon, thanks for letting me know. I know nothing about Nix so I can't be of any help, but I'm glad you've found some workarounds. @gavinleroy lmk if you have any ideas.
Hi @StealthyKamereon 👋 I haven't run into the issue that you've described. I recently started using Nix (read, everything I do could be slightly broken) and you may find the shell env for my current project useful. It's located here, I use flakes, but I don't see any major differences between the two configurations on first glance.
Edit, the main difference is how I load the toolchain from a rust-toolchain.toml
, but I don't think that should make a difference.
Hello,
I would like to make a plugin on Nixos but I'm facing problems. I get the following error:
unresolved extern crate
on:However, if I
cargo check
everything compiles fine.I have poured tens of hours trying to understand what's wrong. I would greatly appreciate if someone see's something I'm missing.
I hope this could serve as a documentation for other people using Nixos.
My environment is the following
shell.nix
This allows to build all the required components.
Code
I have cloned the crates/rustc_plugin/examples/print-all-items example. I made some tweaks that I feel relevant. In
Cargo.toml
:I also set the following setting in rust-analyzer's config:
Thanks in advance