How to make sure rustc uses correct glibc on nixos?

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?

I looked into my nix-tree for the shell.nix derivation and there’s absolutely no glibc-2.33 (or 2.34) in it – only 2.35. How can I figure out where the dep on 2.33 is pulled from?

Are you mixing different nixpkgs which have different glibc versions? Do you have LD_LIBRARY_PATH set?

As far as I’m aware I only depend on unstable. Here’s my flake.nix.

Yeah, then no idea.

Inputs:
├───crane: github:ipetkov/crane/78f7d689fbce672ad5c0ed5ecc666ba508a7d7b8
│   ├───flake-compat: github:edolstra/flake-compat/b4a34015c698c7793d592d66adbab377907a2be8
│   ├───flake-utils: github:numtide/flake-utils/c0e246b9b83f637f4681389ecabcb2681b4f3af0
│   └───nixpkgs follows input 'nixpkgs'
├───flake-compat: github:edolstra/flake-compat/b4a34015c698c7793d592d66adbab377907a2be8
├───flake-utils: github:numtide/flake-utils/c0e246b9b83f637f4681389ecabcb2681b4f3af0
└───nixpkgs: github:NixOS/nixpkgs/a13d59408da1108fc6c9ffe4750ab7a33c581d24

Does ldd give you any hints?