For example, I have a python package that requires libstdc++.so.6.
So my immediate solution was to
find -L /run /nix -name libstdc++.so.6
The result was (sans error messages about permission or symlink loops)
/nix/store/6ll1qmkb3ifgb0srch7j7mylab06v1d5-gcc-6.5.0-lib/lib/libstdc++.so.6
/nix/store/7fvwr8la2k701hrx2w5xnvjr5kkc7ysv-gcc-8.3.0-lib/lib/libstdc++.so.6
/nix/store/6irhcjmdd6ifnlm270y2bhp188la6n23-gcc-6.5.0-lib/lib64/libstdc++.so.6
/nix/store/6irhcjmdd6ifnlm270y2bhp188la6n23-gcc-6.5.0-lib/lib/libstdc++.so.6
/nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib64/libstdc++.so.6
/nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib/libstdc++.so.6
/nix/store/dhn13r8xx087xpyd6y3mrvl4c96ilmwb-gfortran-7.4.0-lib/lib64/libstdc++.so.6
/nix/store/dhn13r8xx087xpyd6y3mrvl4c96ilmwb-gfortran-7.4.0-lib/lib/libstdc++.so.6
Then I just ran
env LD_LIBRARY_PATH=/nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib:$LD_LIBRARY_PATH python
And problem solved.
Of course, this is not the proper nix-way. So what are the proper nix-ways if I were to
make /nix/store/784rh7jrfhagbkydjfrv68h9x3g4gqmk-gcc-8.3.0-lib/lib/libstdc++.so.6 available either
in a shell temporarily,
system-wide by default (preferring gcc 8.3.0 over older gcc), or
for a specific user by default?
Moreover, regarding how nixos works:
Why libstdc++.so.6 is only available in /nix/store/*/lib but not /run/current-system/sw/lib ?
In another occasion I used
From a very first intuitive thaught, I’d say, the proper way is to provide whatever is necessary for building as a buildInputs. propagatedBuildInputs if nix can’t recognize on its own, that the dependency indeed is used…
$ nix eval --raw nixpkgs.zlib
error: experimental Nix feature 'nix-command' is disabled; use '--extra-experimental-features nix-command' to override
Also doesn’t work:
$ nix --extra-experimental-features nix-command eval --raw nixpkgs.zlib
path '/home/rkjnsn/nixpkgs.zlib' does not contain a 'flake.nix', searching up
error: getting status of '/home/rkjnsn/nixpkgs.zlib': No such file or directory
In your case (as you obviously don’t have enabled flakes) an additional --extra-experimental-features "nix-command flakes" would be necessary.
And if you do not want to enable flakes or any other experimental feature, not even temporary, then nix-instantiate might help:
$ nix-instantiate --expr '(import <nixpkgs> {}).zlib'
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
/nix/store/l25hhx6c3jdgkh2vi58k3mf2fbvs0377-zlib-1.2.12.drv