Solution(s)

To solve this, we could patch the precompiled binaries to “un-hard-code” the binary paths. But a better solution is to write Nix derivations to compile lwjgl, as well as gdx itself (they are open-source, after all!). Writing these derivations is pretty easy, since all the required dependencies are already contained in nixpkgs. You can find the results in our gdx overlay. Using these, we can, for example, enter a nix shell, causing the libraries to be built.

Secondly, we need to tell gdx to not use its own extract-and-load logic and do it ourselves. I’ll describe this for libgdx. lwjgl and OpenAL are handled just the same. To locate gdx in the nix store, we use the following command:

nix-build --no-out-link '<nixpkgs>' -A gdx

This path, plus the name of the library, gets us the absolute library location. Teaching libgdx to load it from there involves just one line of Java scalpelling:

System.load(nixosPath+"/lib/libgdx.so"); SharedLibraryLoader.setLoaded("gdx");