[Nix-dev] nix function patchelfExecutables - does this make sense?

Eelco Dolstra eelco at cs.uu.nl
Wed Aug 15 14:47:17 CEST 2007


Hi,

Marc Weber wrote:

> Could be applied to ghcboot and acroread (if buildInputs would be used
> instead of libPath ..  adding more libraries to rpath than necessary
> doesn't harm, does it? As long as they belong to the nix system ..)

Yes, that shouldn't hurt (except that it can cause a "retained" runtime
dependency - you might end up with some paths in the closure that aren't
needed).  In fact you could patchelf again (with --shrink-rpath) to get rid of
unnecessary paths.

>   patchelfExecutables = drv : drv // {

This won't work because "drv" is the result of a call to mkDerivation, and only
the attributes passed in the actual call to mkDerivation will be passed to the
builder.  Any attributes added to the *result* of mkDerivation won't be used.

The solution is to add the postBuild attribute *before* the call to
mkDerivation.  The overrideGCC function in all-packages.nix does something
similar, namely setting the NIX_GCC attribute:

  overrideGCC = stdenv: gcc: stdenv //
    { mkDerivation = args: stdenv.mkDerivation (args // { NIX_GCC = gcc; });
    };

But maybe it simpler to just stick your postBuild value in a file that you can
then import in every Nix expression that needs it.

-- 
Eelco Dolstra | http://www.cs.uu.nl/~eelco



More information about the nix-dev mailing list