Problems building raylib-rs

Maybe a config error but couldn’t find anything related
I’m trying to build an application based on raylib-rs on my laptop running Wayland on NixOS.
The program builds normally but when I try to run the executable I get the following error:

WARNING: GLFW: Error: 65542 Description: GLX: Failed to load GLX
WARNING: GLFW: Failed to initialize Window
thread 'main' panicked at /home/bm69/.cargo/registry/src/index.crates.io-6f17d22bba15001f/raylib-3.7.0/src/core/mod.rs:208:13:
Attempting to create window failed!
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Note that the “wayland” feature is no longer recognized so the readme is outdated as of version 3.7.
Here are the packages I’m installing in my flake.nix file:

    devShells = forEachSupportedSystem ({pkgs}: {
      default = pkgs.mkShell {
        packages = with pkgs; [
          rustToolchain
          openssl
          pkg-config
          cargo-deny
          cargo-edit
          cargo-watch
          rust-analyzer
          cmake
          gnumake
          pkg-config
          libGL
          xorg.libX11
          xorg.libX11.dev
          xorg.libXft
          xorg.libXrandr
          xorg.libXinerama
          xorg.libXcursor
          xorg.libXi
          libatomic_ops
          mesa
          alsa-lib
          glibc
          # [Wayland]
          wayland
          wayland-protocols
          libxkbcommon
          glfw-wayland
        ];
      };
    });

Some of the glfw packages listed on the readme weren’t availble on nixpkgs.
Any help is appreciated

@hanzy1110 have you made any progress on this?

EDIT: I have figured it out:

let libs = with pkgs; [
  libGL
  wayland
  xorg.libXrandr
  xorg.libXinerama
  xorg.libXcursor
  xorg.libXi
];
in
{
  devShell = pkgs.mkShell {
    packages = with pkgs; [
      rustup
      cmake
      clang
      pkg-config
    ] ++ libs;
    LD_LIBRARY_PATH = libs;
    LIBCLANG_PATH = "${pkgs.llvmPackages_11.libclang.lib}/lib";
  };
}

EDIT 2: the build works fine, but the app doesn’t run (on wayland at least)
EDIT 3: toggling the wayland feature for raylib-rs made the app run

1 Like

Thanks!! Let me try this and get back to you.
EDIT: Are you building raylib from source?
cargo add raylib -F wayland doesn’t work!
EDIT2: Building from source now, how did you deal with the library/build paths? I’m having troubles with raylib finding libclang, even though I’m specifying it in pkgs and in LD_LIBRARY_PATH and. Also it tries to mkdir into /var/empty which the build process doesn’t have permission to

1 Like

The LIBCLANG_PATH thing gives it the path to well… libclang.

And yes, I’m building it like you pointed out (I added it with cargo add raylib and later toggled the wayland feature). I haven’t run into the /var/empty issue. Can you post your code and the error?

EDIT: note that I’m not sure what app you’re building. I was setting up a personal project where, at the moment, raylib is the only dep.

I made some mistakes in the previous snippet, here’s a simplified one:

devShell = pkgs.mkShell {
  packages = with pkgs; [
    rustup
    cmake
    clang
    pkg-config
    wayland
    glfw
  ];
  LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath [
    libGL
    xorg.libXrandr
    xorg.libXinerama
    xorg.libXcursor
    xorg.libXi
  ];
  LIBCLANG_PATH = "${pkgs.llvmPackages_11.libclang.lib}/lib";
};