[Nix-dev] purifying cmake - need to determine buildInputs directories in a setup hook

Luis Torres lgtorres42 at gmail.com
Sat Mar 28 20:54:13 CET 2015


Currently, when building cmake projects in Nix, cmake will sometimes try to
pull in headers/libraries from impure directories like /usr. I think I've
found the way to disable this behavior, but I need some help writing the
derivation/scripts to do this.

If the cmake command is invoked with the following flags:

-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY

then cmake will *only* search for libraries and headers in paths specified
with the following flag:

-DCMAKE_FIND_ROOT_PATH=<list of search paths separated by semicolons>

My idea is to modify cmake's setup-hook.sh so that, when building a
derivation that depends on cmake, the cmake command automatically gets
called with the above flags, and CMAKE_FIND_ROOT_PATH only contains
directories specified in the derivation's buildInputs attribute.

This is where I need assistance: in cmake's setup-hook.sh, how can I get a
list of all the directories listed as buildInputs to the derivation?

The current setup-hook.sh finds all the dependencies' include/ and lib/
directories by looking at NIX_CFLAGS_COMPILE and NIX_LDFLAGS, but what I
actually need are all the dependencies' root directories (i.e., I need
$package, not $package/include).

Thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20150328/6b541c59/attachment.html 


More information about the nix-dev mailing list