nix-community / fenix

Rust toolchains and rust-analyzer nightly for Nix [maintainer=@figsoda]
Mozilla Public License 2.0
608 stars 39 forks source link

Setting Rust source path #141

Open psionic-k opened 3 months ago

psionic-k commented 3 months ago

The README seems to indicate that having the rust-src attribute in the shell's packages would automatically set RUST_SRC_PATH

rust-src = <derivation>; # RUST_SRC_PATH = "${fenix.complete.rust-src}/lib/rustlib/src/rust/library"

It's a good idea, but it doesn't seem to happen. My toolchain was constructed like so:

          rustToolchain = with pkgs.fenix; combine [
            targets.x86_64-unknown-linux-musl.stable.rust-std
            stable.rust-src
            stable.rustc
            stable.cargo
          ];

And then included in a shell like so:

          shell = pkgs.mkShell
            {
              buildInputs = [
                rustToolchain
                pkgs.pkg-config
                pkgs.libusb1
              ];
              RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
              RUST_BACKTRACE = 1;

              PKG_CONFIG_ALLOW_CROSS=1;
            };

The availability of rustc and cargo within the shell are as expected.