Can't run a Godot Engine binary nix-ld

I am trying to run a course binary for Godot engine, which has practice projects and plugins preinstalled. Unfortunately, I’m running into a display issue with Wayland and x11 when I try to run it.

Here is the exact error I get with running the binary:

./Godot_v4.4-stable_linux.x86_64
libfontconfig.so.1: cannot open shared object file: No such file or directory
Godot Engine v4.4.stable.official.4c311cbee - https://godotengine.org
libX11.so.6: cannot open shared object file: No such file or directory
ERROR: Can't load Xlib dynamically.
   at: DisplayServerX11 (platform/linuxbsd/x11/display_server_x11.cpp:6483)
WARNING: Display driver x11 failed, falling back to wayland.
     at: setup2 (main/main.cpp:3022)
libwayland-client.so.0: cannot open shared object file: No such file or directory
WARNING: Can't load the Wayland client library.
     at: init (platform/linuxbsd/wayland/wayland_thread.cpp:3891)
ERROR: Could not initialize the Wayland thread.
   at: DisplayServerWayland (platform/linuxbsd/wayland/display_server_wayland.cpp:1417)
ERROR: Can't create the Wayland display server.
   at: create_func (platform/linuxbsd/wayland/display_server_wayland.cpp:1391)
ERROR: Unable to create DisplayServer, all display drivers failed.
Use "--headless" command line argument to run the engine in headless mode if this is desired (e.g. for continuous integration).
   at: setup2 (main/main.cpp:3032)
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2378)

I have tried installing the xlib packages didn’t work, so I uninstalled them, here is a paste with config.
I am fairly new to Linux and NixOS in general, so anything you need, please ask!

I found the comments in the code :grin::

   programs.nix-ld.libraries = with pkgs; [
    # Add any missing dynamic libraries for unpackaged programs
    # here, NOT in environment.systemPackages
  ];

Try adding fontconfig, wayland, and libX11 to programs.nix-ld.libraries. These might not be enough, if it doesn’t work, copy the dependencies from nixpkgs godot. Also remove them from environment.systemPackages

export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH before running this binary

Hi, thanks for the reply, I ended up switching distros since I still couldn’t get it to work. I however, will enjoy using the nix package manager as before. Thanks!