Can't setup Rust for Bevy

I’m trying to set up my rust project (using bevy with wayland). According to the bevy docs, I just need to set it up like so:

{ pkgs ? import <nixpkgs> { } }:

with pkgs;

mkShell rec {
  nativeBuildInputs = [
    pkg-config
  ];
  buildInputs = [
    udev alsa-lib vulkan-loader
    xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature
    libxkbcommon wayland # To use the wayland feature
  ];
  LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
}

However, I can’t seem to get it to work in the dev.nix file?

No matter what I try, I keep getting the errors (I’ve tried adding packages, & editing the PCG_CONFIG_PATH):
The system librarywayland-clientrequired by cratewayland-syswas not found. The filewayland-client.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
PKG_CONFIG_PATH contains the following:
- /usr/lib/pkgconfig

HINT: you may need to install a package such as wayland-client, wayland-client-dev or wayland-client-devel.
This also happens with “Alsa” where it wants an alsa-sys pkg which doesn’t seem to exist.

Any help is greatly appreciated :+1:

Nevermind! I solved it :smile:
Turns out I needed to use the dev versions of the packages!

Leaving it here for future reference:


# .idx/dev.nix
{ pkgs, lib, ... }: {
  channel = "unstable";

  packages = (with pkgs; [
    rustup
    stdenv.cc
    pkg-config
    zstd
    libxkbcommon
    vulkan-loader
    xorg.libX11
    xorg.libXcursor
    xorg.libXi
    xorg.libXrandr
    alsa-lib.dev
    wayland.dev
    udev.dev
  ]);
}
1 Like

Not related, but I want to mention that if you suffer any segmentation fault out of nowhere because you’re using unstable channel, it’s because some part of the code is using std::time::Instant::now()

https://issuetracker.google.com/issues/360159393

1 Like

This is really cool! :slight_smile:

Have you considered creating a template out of this and posting it on Github? That may be an easy way for others who are running into this get up and started with this project in IDX.

Well, to be completely honest, I have neither the experience or expertise with nix or rust to do that. Matter of fact, I actually couldn’t get rust to link properly after setting up the pkgs :sweat_smile:!

Would definitely love to see a template for this kind of thing though

1 Like

What errors showed up for Bevy?