I want to roll back for a minute and explain the first part; please feel free to ignore this paragraph if you do not care. For what its worth, the not found error is correct, just misleading. A file is not found. What’s happening is that something (your shell) is eventually calling the Linux ‘exec’ syscall, which runs the ELF binfmt module (the module which loads ELF files, the type of executable generally used on Linux.) Most ELF binaries are dynamically linked, which just means they link to shared objects. The OS kernel doesn’t typically handle actually loading these modules. Instead, the ELF file specifies another file on disk; the kernel loads this file, the dynamic linker, which then performs the actual work. The problem is that this file is typically at a specific location, like /lib64/ld-linux-x86-64.so.2
, which isn’t present on NixOS: all NixOS libraries go into the Nix store so that the version of a library never changes by surprise. So the kernel returns a typical file not found error. Unfortunately, syscall errors don’t distinguish between the file you tried to execute not being found and the linker it needs not being found.
OK. As eljamm has pointed out, the most correct thing to do from a NixOS standpoint is try to use Nix as intended, which can be done a couple of ways. You can use NixOS-compiled binaries like the JRE, which will provide the best integration into NixOS.
However I worry that a lot of stuff may expect to be able to use shared objects that link to system libraries. In this case, you may need something more advanced, like Nix-LD or an FHS environment. The Nix-LD approach is useful if you really just want to be able to use the normal software as it would run elsewhere; I recommend giving it a shot if you aren’t able to get this working.
If you are interested in trying the Nix-LD approach, I can’t find a great third party resource, but please feel free to check the compat.nix module in my own NixOS configuration. It may have more or less libraries than you need, but it should make it possible to use the raw binaries that work on other Linux systems.
Sorry if this isn’t useful. I generally think using Nix-based solutions is overall the best way to go, but I think it’s immensely useful to have a system Nix-LD configuration, and I use it all the time for running random binaries.
The FHS approach is even more likely to work, as it emulates even more of the standard Linux system, but it’s a bit harder to set up.