A clear and concise description of what the bug is.
default.nixlet
moz_overlay = import (builtins.fetchTarball
"https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz");
nixpkgs = import <nixpkgs> { overlays = [ moz_overlay ]; };
ruststable = (nixpkgs.latest.rustChannels.stable.rust.override {
extensions = [ "rust-src" "rls-preview" "rust-analysis" "rustfmt-preview" ];
});
in with nixpkgs;
stdenv.mkDerivation {
name = "rust";
buildInputs = [
openssl
nasm
rustup
ruststable
pkgconfig
cmake
zlib
xorg.libX11
xorg.libXcursor
alsaLib
freetype
expat
];
shellHook = ''
export OPENSSL_DIR="${openssl.dev}"
export OPENSSL_LIB_DIR="${openssl.out}/lib"
'';
}
nix-shell to create environmentBlank screen titled pong!
Finished dev [unoptimized + debuginfo] target(s) in 0.14s
Running `target/debug/pong`
thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoCompositorListening X11 status: LibraryOpenError(OpenError { kind: Library, detail: "opening library failed (libXcursor.so.1: cannot open shared object file: No such file or directory); opening library failed (libXcursor.so: cannot open shared object file: No such file or directory)" })', /home/emiller/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.2/src/platform/linux/mod.rs:459:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
0.12I would like to help provide support for nix for the project with some guidance!
This is an issue with anything using winit on NixOS, not specific to Amethyst.
Though I'm not sure _exactly_ what the cause is, I know that it can be fixed (temporarily / per-build) by using patchelf on the file (e.g. target/debug/pong).
(patchelf seems to be available by default in a nix-shell, but not normally otherwise)
Specifically, though there's probably a better or faster method—I seem to recall something involving nix-repl that generated paths like this—I had to find the paths in /nix/store that contained the files it was looking for and couldn't find (find /nix/store -name libXcursor.so.1/etc), choose one of the results, run something like patchelf --set-rpath /nix/store/…-libXcursor-1.2.0/lib:/nix/store/… ./target/debug/pong, and then cargo run again.
If it complained about the same library (something about ELF types or something came up often), I chose a different instance of the library I had in /nix/store and did it again; if it complained about a different one, I added that to the list.
After five or six of these, the example I was trying to get working (from a different library using winit) ran, and it seemed to work fine.
Edit: The method involving nix repl is described in the Extra Dynamic Libraries section on https://nixos.wiki/wiki/Packaging/Binaries.
I've been using this as shell.nix for my projects:
let
mozilla = import (builtins.fetchTarball https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz);
nixpkgs = import <nixpkgs> { overlays = [ mozilla ]; };
in
with nixpkgs;
mkShell {
buildInputs = [
alsaLib
cmake
freetype
latest.rustChannels.stable.rust
expat
openssl
pkgconfig
python3
vulkan-validation-layers
xlibs.libX11
];
APPEND_LIBRARY_PATH = stdenv.lib.makeLibraryPath [
vulkan-loader
xlibs.libXcursor
xlibs.libXi
xlibs.libXrandr
];
shellHook = ''
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$APPEND_LIBRARY_PATH"
export RUSTFLAGS="-C target-cpu=native"
'';
}
This issue can probably be closed, I could PR a note in the documentation on how to use Amethyst on NixOS.
Most helpful comment
2013 was merged, I think this can be closed