4 ms·
Just a minor footnote. My interest in Nix is not high and what there is motivated mostly by the existence of NixOS. Why do I have any interest in NixOS? We bui
by PaulDavisThe1st 6y ago
Just a minor footnote. My interest in Nix is not high and what there is motivated mostly by the existence of NixOS. Why do I have any interest in NixOS?
We build and distribute Ardour (a cross-platform open source DAW) in a single package that runs on every Linux distribution that has libc, libstdc++, and some version of Xlib.
Every Linux distribution that is, except NixOS. They decided to patch the runtime linker so that the approach usable on every other Linux distro breaks there.
This says something about NixOS, and presumably Nix too, though I'm not sure what.
- aidenn0 6y agoI didn't think NixOS patched the runtime linker (though I could definitely be wrong). They do eliminate any ability to automatically find libraries, and the dynamic loader does not exist at the path where it exists on most other distros, which means binaries linked elsewhere will not run unmodified on nixos.
- danieldk 6y agoTo 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).
- kalium-xyz 6y agoI've not heard of anything patched outside of paths being changed by patchelf. This is done because any dependencies are being stored inside the nix store under a hash of their dependency trees, which allows for multiple versions of the same dependency to exist without conflict. You should find that the NixOS community has no problem with producing the nix file to make NixOS support possible for your open source DAW.
- pmahoney 6y agoHi Paul, thanks for Ardour. For anyone curious, this wiki page describes how to package and run some precompiled binaries on NixOS, particularly the section "The Dynamic Loader": https://nixos.wiki/wiki/Packaging/Binaries https://nixos.wiki/wiki/Packaging/Binaries NixOS tries to insist that programs reference only other paths within the nix store (e.g. /nix/store/9rabxvqbv0vgjmydiv59wkz768b5fmbc-glibc-2.30/lib64/ld-linux-x86-64.so.2 which is a specific version built by a specific compiler, rather than /lib64/ld-linux-x86-64.so.2). This is the source of the per-program isolation that enables all the nifty features of NixOS. NixOS _does_ make exceptions to that though, for example providing both /bin/sh and /usr/bin/env at those paths.
- PaulDavisThe1st 6y agoThe key point here is that we want to package things in a distro-independent way. In our distro-independent package there is no store and hence on nixOS it won't run. Note that the way we do things is not unique - Firefox has been packaged this way by the Mozilla Foundation for years. We consider ourselves closer to a "traditional ISV" than merely the provider of source code to the open source community (though obviously, we play the latter roll too). We don't have the resources to spend on a nixOS-specific package, nor the desire. Fortunately, of course, nixOS users can create suitable packages for nixOS, and I think they are. It just says something that out of the myriad flavors of Linux, nixOS is the only one that has broken this rather old concept for packaging software from ISVs. But please, carry on! Seems interesting enough.