Running exported project on NixOS

Godot Version

4.2.1

Question

I’m developing a project in NixOS. I’ve exported it as I used to do in Arch, but when I try to run the exectuable from the CLI I get this error:

zsh: no such file or directory: ./MyProject.x86_64

Even though I’m running it from the directory where the executable is, and it has execution privileges.

I’m not sure how to proceed. My guess is that the export tool compiles for “regular” linux distro, and I’ve read somewhere that it may have to do with dynamic libraries.

So, how am I supposed to run the binary while in NixOS? I’ve read in the mentioned post about steam-run and other workarounds, but, is there an out-of-the-box solution in Godot, like a dedicated export preset for NixOS, or some special tweaking like compiling with static instead of dynamic libraries so everything is in one place (flatpak, maybe --never used it–)?

Thanks!

Official Godot binaries already make heavy use of static linking, but one exception is glibc. Binaries are compiled using build containers which link against an old enough glibc version, so the binary works on LTS Linux distributions out of the box. However, this doesn’t suffice for non-glibc based distributions such as Alpine Linux (which use musl instead). For these distributions, you’ll need to compile Godot from source on the same system to be able to run the binary.

You can use ldd path/to/binary to check which dynamic libraries a binary links against.

Last time I checked, musl is suitable for headless Godot binaries, but not for full-blown Godot binaries that need OpenGL/Vulkan due to OpenGL library linking issues.

thanks for the reply. I understand.

I have 2 questions,:

  1. isn’t Godot compiled for NixOS if I installed it through Home Manager?
  2. if I need to use a different compiled version, will it affect exporting to the other 3 major platforms (OSX, Win and LTS Linux distros)?

The editor is, but export templates are not. Assuming NixOS does not package the export templates itself, you’ll be using the official export templates downloaded with the export template manager. Even if NixOS packages the export templates, it might just be a copy of the official export templates, not purpose-built binaries.

The editor’s export process does not actually compile binaries. Instead, it copies a precompiled export template binary next to a generated PCK file (which contains the project data). This means that regardless of which platform you export from, the generated output is the same.

Great, I’ll try to compile it for NixOS, then.

Thanks!

I just found about these ways of running non-NixOS binaries in this post. Would this also work for running exported projects? As the post is a bit old, are there up-to-date solutions to do the same or are these still valid?

I have no idea on how to compile the project for NixOS, and will need to find out how to do it if there’s no other solution. But if there’s a simpler way to run them, I’d be happy to know.

I managed to play the binaries with steam-run.

Just for future reference, installing steam-run has to be done in the /etc/nixos/configuration.nix (it didn’t work in home-manager):

programs.steam.enable = true;

environment.systemPackages = [
  pkgs.steam-run
];

Then simply run:

steam-run path/to/binary.x86_64