I’m new to developing on nix and I’m running into a problem with rust-analyzer.
It previously complained about a lot of things, but I worked them out with this shell.nix file:
with import <nixpkgs> { };
stdenv.mkDerivation {
name = "rust-env";
nativeBuildInputs = [
# Build-time dependencies
rustc
cargo
llvmPackages.clang
glibc
glibc.dev
pkg-config
libclang
ffmpeg
];
buildInputs = [
# Run-time dependencies
ffmpeg
];
# Environment variables
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
TMPDIR = "";
}
I also added the nix environment selector extension and installed direnv.
Now everything compiles without warnings, but rust-analyzer still displays a warning for some reason. Here it is in full:
WARN `cargo metadata` failed and returning succeeded result with `--no-deps` error=`cargo metadata` exited with an error: Updating crates.io index
error: failed to create directory `/nix/store/wf9lnfvq4x0b1zh22i2q9b1vnrk0i8pj-rust-lib-src/rust-analyzer9311-4`
Caused by:
Read-only file system (os error 30)
Stack backtrace:
0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
1: project_model::cargo_workspace::FetchMetadata::exec
2: project_model::sysroot::Sysroot::load_workspace
3: std::sys::backtrace::__rust_begin_short_backtrace
4: core::ops::function::FnOnce::call_once{{vtable.shim}}
5: <std::sys::thread::unix::Thread>::new::thread_start
6: start_thread
7: __clone3
It also generates directories like proc-macro-srv9e6f-0 in the project root, which I’m not sure is intended.
Here are the dependencies for the project:
[dependencies]
clap = { version = "4.6.6", features = ["derive"] }
ffmpeg-next = "9.0.0"
Can someone explain what I’m doing wrong and how to fix it?