I came across https://bevyengine.org/ , a game engine in Rust and I want to run their example in NixOS. I am able to compile their example, a reproducible repo with flake support available here for testing:
But right now I am getting this error, despite I am using X11. How can I fix this?
I had something similar with another game engine I wanted to try.
IIRC it was because the library responsible for dynamic loading of drivers used hardcoded pathes.
Back then I didn’t have the time and energy to go deeper than that or even trying to fix, as I wouldn’t have known a portable way to fix it either…
Perhaps you are affected by the same problem?
winit and follow how it’s loading the libs.
That’s the biggest learning hurdle in NixOS. By default, nothing knows where to find the packages in you the nix store, you must “expose” it within a shell or nix build.
libX11.so.6, you want the
$ nix-locate libX11.so.6 --top-level
remarkable2-toolchain.out 0 s /nix/store/niwh39q61h6s7c127zf0a7291ajjzc6j-remarkable2-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/lib/libX11.so.6
remarkable2-toolchain.out 1,285,512 x /nix/store/niwh39q61h6s7c127zf0a7291ajjzc6j-remarkable2-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/lib/libX11.so.6.3.0
remarkable-toolchain.out 0 s /nix/store/597yy4hjagq973c07cr347ms84hhq1qw-remarkable-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/lib/libX11.so.6
remarkable-toolchain.out 1,285,512 x /nix/store/597yy4hjagq973c07cr347ms84hhq1qw-remarkable-toolchain-3.1.2/sysroots/x86_64-codexsdk-linux/usr/lib/libX11.so.6.3.0
nxproxy.out 0 s /nix/store/xr23g4180gb1fvwwcx8kpkdd84fixka3-nx-libs-188.8.131.52/lib/nx/X11/libX11.so.6
nxproxy.out 0 s /nix/store/xr23g4180gb1fvwwcx8kpkdd84fixka3-nx-libs-184.108.40.206/lib/nx/X11/libX11.so.6.3.0
xlibs.libX11.out 0 s /nix/store/avqk9invc40jg7sh57y0nmpnccz5nm1d-libX11-1.7.2/lib/libX11.so.6
xlibs.libX11.out 1,433,520 x /nix/store/avqk9invc40jg7sh57y0nmpnccz5nm1d-libX11-1.7.2/lib/libX11.so.6.4.0
(xlibs was the old name)
You will probably miss other dependencies, here is what I had in a recent bevy project:
I thought I am fine already as I am using X11 on my machine already? I thought
direnv will just change
$PATH, I didn’t realize it will hide shared objects as well
Do you mean this rust lib, as it is the lib that interact with X11?
winit - Rust.
I’m not sure if it was the one I had trouble with…
@Greizgh I have tried to add more deps there, but still I am hitting the same error. can you try and run this one your end and see if you can find anything?
cargo run --example breakout
I can confirm that by adding in those dependencies I have fixed that error, but got a new one down below
We need some great people to create a starter template in NixOS/template for this …
Hm I am now hitting this:
2022-02-03T22:32:28.770646Z INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 2.3333333333333335
thread 'main' panicked at 'Unable to find a GPU! Make sure you have installed required drivers!', crates/bevy_render/src/renderer/mod.rs:74:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
on NixOS, the userland video drivers are mounted to
/run/opengl-driver/lib/. Unfortunately, this is kind of a hidden option.
hardware.opengl.enable = true;
I made it working by enabling
opengl, and have the following dev shell:
devShell = with pkgs;
nativeBuildInputs = [
lld # To use lld linker
buildInputs = [
#NOTE Add more deps
shellHook = ''
RUST_SRC_PATH = rustPlatform.rustLibSrc;
@NobbZ you might want to give it a try