opencog / opencog-nix

Build definitions for the NIX package manager
7 stars 4 forks source link

Symlink $out/lib/opencog/* to $out/lib/ #57

Closed Radivarig closed 3 years ago

Radivarig commented 4 years ago

The difference between nix and non-nix builds is that it puts the output in /nix/store/../ and what would end up in /lib on non-nix systems ends up in /nix/store/../lib.

In nix, if the buildInputs contains for example python or guile packages, shell variables PYTHONPATH and GUILE_LOAD_PATH are automatically extended with the $out/lib/python${version}/site-packages and $out/share/guile/site of the derivation result, and same for LD_LIBRARY_PATH with $out/lib (this is not true, a custom setupHook is needed).

Since opencog often places modules into /lib/opencog including those paths once somewhere is sufficient for all of /lib/opencog/* to be available in the library path, but in nix this requires adding one $out/lib/opencog per output.

Example of this workaround is here: cogserver/default.nix and opencog/default.nix.

Note that some packages also write to /lib/opencog/modules or other paths, depending on the makefiles.

Radivarig commented 3 years ago

setupHook will be called when a package is included in buildInputs which makes it convenient to auto extend all needed shell variables with custom library paths without having to do it manually in the shellHook.