3 ms·
To expand a bit on this for people not familiar with Nix: the dynamic linker is treated as any other dependency and therefore stored in the Nix store, using the
by danieldk 6y ago
To expand a bit on this for people not familiar with Nix: the dynamic linker is treated as any other dependency and therefore stored in the Nix store, using the derivation's hash as part of the store path.
The binary's .interp section indicates which dynamic linker must be used. On a regular Linux distribution, you will find that this is a global path:
$ readelf -p .interp $(which cp)
String dump of section '.interp':
[ 0] /lib64/ld-linux-x86-64.so.2
No global library paths such as /lib or /lib64 exists on NixOS. This is one of the reasons why binaries compiled on other Linux distributions, such as Ubuntu, do not work out of the box. And you have to use patchelf to change the dynamic loader's path.
Instead, the dynamic loader of the glibc version that a program was built against is used:
$ readelf -p .interp $(which cp)
String dump of section '.interp':
[ 0] /nix/store/jx19wa4xlh9n4324xdl9rjnykd19mmq3-glibc-2.30/lib/ld-linux-x86-64.so.2
- solarkraft 6y agoWhy aren't there symlinks for things standard linux directories, a bit like current-system in the user environment? Why go through the effort of patching the actual binary? Doesn't that cause enormous problems with signed stuff? Edit: I assume you can't do it very well system-wide because individual packages might need conflicting versions. Okay. Has something like runtime injection been considered? What are the trade-offs here? (I think it's fairly obvious that I'm not very familiar with the whole matter yet).