What would be issues with adding all packages to programs.nix.libraries?

Soneone suggested in the nixpkgs repo to Add option in nix-ld module to load all libraries installed in the system, I read through it, but would like to know exactly why it would be an issue other than “NixOS is not intended to be used in this manner … fighting NixOS to work in an FHS-compliant manner”:

https://github.com/NixOS/nixpkgs/issues/354513#issuecomment-2465688721
I’ll be completely honest with you, this is a very bad decision. nix-ld was designed to help simplify the execution of apps that would require some form of wrapping/rebuilding to work in Nix/NixOS. It’s a great tool to use when you want to avoid headaches, but you’ve genuinely used it too far. NixOS is not intended to be used in this manner, because youre really just fighting NixOS to work in an FHS-compliant manner when it does everything against that principle. At this point you would generally be better off using a standard FHS distro and avoiding Nix/NixOS entirely.
I dont mean this in a disrespectful way at all, just want to point out that this is really making more work for you than its worth, and would cement a very bad practice for NixOS users by encouraging this usage. You’re practically ditching all the benefits of NixOS and Nix by proxy, to try and make FHS-compliant things work this way. It’s really no different than just using any other distro with its package manager.
I should also add I’m very against this type of addition, it encourages people to just set and forget nix-ld, which is not a practice NixOS users should get comfortable with.

Discounting the design choice and ideological issues:

First problem: “All libraries installed on the system” almost certainly has collisions, where distinct versions of the same library are both installed. (Assuming “installed” means “in the closure of the system” in some sense, since library packages are not, and should not be, in environment.systemPackages directly…)

Second problem: Likely recursion issues if you try to get too complete with the meaning of “all”. If it’s just dependencies of what’s in environment.systemPackages, though, that would work.

Third problem: This is already an issue, but using nix-ld globally at all can cause mis-packaged programs to happen to behave correctly in some environments, detracting from the reproducibility of nix packaging in practice. This becomes a bigger issue the more widespread its use is among nixpkgs contributors, and thus, making it easier to do so is often met with fierce resistance by those who understand this danger.

5 Likes

That is the issue.
The whole reason for this nix concept is to ensure programs are linked against their libraries correctly. NixOS is the distro that uses nix for deployment. Using nix-ld globally is how you guarantee things break.

Why use NixOS if you don’t want its benefit? Why do you want programs to break and libraries to collide?

Go to the comments of any remotely popular AUR package for example, we have seen how the “stuff everything in /usr/lib” model does not work.

3 Likes