amethyst / space-menace

An action 2D platformer made with Amethyst game engine
MIT License
180 stars 32 forks source link

Cannot run on NixOS #35

Closed ThibaultLemaire closed 4 years ago

ThibaultLemaire commented 5 years ago

I have managed to compile on NixOS, but the resulting executable can't find its runtime dependencies (specifically libXrandr.so.2 but I suspect the issue will happen again with other dependencies).

Command:

nix-shell -p rustup pkg-config openssl alsaLib xorg.libX11 xorg.libXrandr cmake python3 freetype expat --run 'cargo run'

Output:

    Finished dev [unoptimized + debuginfo] target(s) in 6.16s
     Running `target/debug/space-menace`
thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoCompositorListening X11 status: LibraryOpenError(OpenError { kind: Library, detail: "opening library failed (libXrandr.so.2.2.0: cannot open shared object file: No such file or directory); opening library failed (libXrandr.so.2: cannot open shared object file: No such file or directory); opening library failed (libXrandr.so: cannot open shared object file: No such file or directory)" })', /home/naughtylus/.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.

(This is a dev build, but the same happens with a release build)

This is the first Rust project I try to compile on NixOS, I'll ask on the Nix Matrix room for insights.

eleidan commented 5 years ago

HINT: The following command reveals all the run-time dependencies, AFAIK:

$ ldd <binary>

For instance:

$ ldd /usr/bin/docker
    linux-vdso.so.1 =>  (0x00007ffde665a000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f34e9df0000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f34e9bec000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f34e9822000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f34eebae000)
ThibaultLemaire commented 5 years ago

All dependencies are found

❯ ldd target/debug/space-menace
        linux-vdso.so.1 (0x00007ffddef94000)
        libssl.so.1.1 => /nix/store/nrnnvdy72487sv5n83qa04lafbl6nbcl-openssl-1.1.1c/lib/libssl.so.1.1 (0x00007f4fb6a8f000)
        libcrypto.so.1.1 => /nix/store/nrnnvdy72487sv5n83qa04lafbl6nbcl-openssl-1.1.1c/lib/libcrypto.so.1.1 (0x00007f4fb67a0000)
        libfreetype.so.6 => /nix/store/v0dy9gcr12vf63lyq69nrpgzm3yz5wlz-freetype-2.10.1/lib/libfreetype.so.6 (0x00007f4fb66e0000)
        libexpat.so.1 => /nix/store/n7i4v3zz3xqg94w2wavdxj77g3gr18if-expat-2.2.7/lib/libexpat.so.1 (0x00007f4fb66a3000)
        libasound.so.2 => /nix/store/8i03vc4n2a6lhd7s713ahhnhhay04j4a-alsa-lib-1.1.9/lib/libasound.so.2 (0x00007f4fb659d000)
        libxcb.so.1 => /nix/store/ynmrvr48grbwcr9nhv80indfndzwyg4r-libxcb-1.13.1/lib/libxcb.so.1 (0x00007f4fb6572000)
        libxcb-render.so.0 => /nix/store/ynmrvr48grbwcr9nhv80indfndzwyg4r-libxcb-1.13.1/lib/libxcb-render.so.0 (0x00007f4fb6562000)
        libxcb-shape.so.0 => /nix/store/ynmrvr48grbwcr9nhv80indfndzwyg4r-libxcb-1.13.1/lib/libxcb-shape.so.0 (0x00007f4fb655c000)
        libxcb-xfixes.so.0 => /nix/store/ynmrvr48grbwcr9nhv80indfndzwyg4r-libxcb-1.13.1/lib/libxcb-xfixes.so.0 (0x00007f4fb6552000)
        libX11.so.6 => /nix/store/690qkhaj8mvr6ax949gz16a69wn5fcxs-libX11-1.6.8/lib/libX11.so.6 (0x00007f4fb640f000)
        libdl.so.2 => /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libdl.so.2 (0x00007f4fb6408000)
        librt.so.1 => /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/librt.so.1 (0x00007f4fb63fe000)
        libpthread.so.0 => /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libpthread.so.0 (0x00007f4fb63dd000)
        libgcc_s.so.1 => /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libgcc_s.so.1 (0x00007f4fb61c7000)
        libc.so.6 => /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libc.so.6 (0x00007f4fb6011000)
        /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/ld-linux-x86-64.so.2 => /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib64/ld-linux-x86-64.so.2 (0x00007f4fb9451000)
        libm.so.6 => /nix/store/6yaj6n8l925xxfbcd65gzqx3dz7idrnn-glibc-2.27/lib/libm.so.6 (0x00007f4fb5e7b000)
        libbz2.so.1 => /nix/store/5dn03xfw3wimm78nfpg67p1zj1025sbc-bzip2-1.0.6.0.1/lib/libbz2.so.1 (0x00007f4fb5e66000)
        libpng16.so.16 => /nix/store/6friwcmy1yck5jh7l2nrd1503igafqsg-libpng-apng-1.6.37/lib/libpng16.so.16 (0x00007f4fb5e2d000)
        libz.so.1 => /nix/store/62ar9xmrlcnlgmwgfi77xz6bq1180vhi-zlib-1.2.11/lib/libz.so.1 (0x00007f4fb5e0e000)
        libXau.so.6 => /nix/store/ramhsw6khg128qvysraqlagcw8klg1ii-libXau-1.0.9/lib/libXau.so.6 (0x00007f4fb5e09000)
        libXdmcp.so.6 => /nix/store/1k9nbcb6avap3c8jcnvabkdgj86wj3vv-libXdmcp-1.1.3/lib/libXdmcp.so.6 (0x00007f4fb5dff000)
ThibaultLemaire commented 5 years ago

I think I'll try to take inspiration from veloren/veloren!506 to write a working derivation

ThibaultLemaire commented 5 years ago

Wait, could it have to do with vulkan? My GPU doesn't support vulkan.

erlend-sh commented 4 years ago

That would be it. We do not yet support OpenGL.

ThibaultLemaire commented 4 years ago

Closing as irrelevant. As far as I could test compilation is successful on NixOS. The support for OpenGL is another issue.