I’ve make a basic rust package following ipetkov/crane’s quick-start-simple. The nix build and cargo build both work as expected from my shell.
I had to tinker with RUST_SRC_PATH
to get rust-analyzer and LSP working from within VSCode. I run VSCode on windows and nixos within WSL (that’s a pure nixos from GitHub - nix-community/NixOS-WSL: NixOS on WSL(2) [maintainer=@nzbr]):
devShells.default = pkgs.mkShell {
inputsFrom = builtins.attrValues self.checks;
buildInputs = my-crate.buildInputs;
nativeBuildInputs = with pkgs; [
cargo
rustc
rust-analyzer
clippy
rust.packages.stable.rustPlatform.rustcSrc
] ++ my-crate.nativeBuildInputs;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
This only works in VSCode thanks to use flake
in the .envrc and direnv extension.
Now, it’s been a long road to get it all working together and it’s almost functional. The basics of LSP do work. What doesn’t work is proc macro handling:
proc macro
main
not expanded: Cannot create expander for /home/nixos/src/kube-cidr-manager/target/debug/deps/libtokio_macros-a639847ca16674fe.so: Io(Custom { kind: InvalidData, error: DlOpen { desc: “/nix/store/0xxjx37fcy2nl3yz6igmv4mag2a7giq6-glibc-2.33-123/lib/libc.so.6: version `GLIBC_2.34’ not found (required by /home/nixos/src/kube-cidr-manager/target/debug/deps/libtokio_macros-a639847ca16674fe.so)” } })rust-analyzerunresolved-proc-macro
Somehow somewhere this thing seems to be built against glibc 2.34. I don’t have rustc outside of this project’s flake so I’m at loss from how I ended up here. Any ideas how to debug this further?