[Nix-dev] PatchELF in Bundix's postBuild step

Maarten Hoogendoorn maarten at moretea.nl
Fri Dec 2 23:54:54 CET 2016


I'm trying to use grpc (http://www.grpc.io/)  from ruby. This gem has some
hardcoded paths in there, and apparently also tries to write to a directory
owned by the ruby interpreter after building a native extension. I've
opened a issue for this at https://github.com/grpc/grpc/issues/8935

2016-12-01 22:29 GMT+01:00 zimbatm <zimbatm at zimbatm.com>:

> Yes that's it. There is also a pkgs.defaultGemConfig that contains common
> overrides, like injecting libxml for the nokogiri gem. You might want to
> merge it with your override (or submit yours to nixpkgs).
>
> On Thu, 1 Dec 2016, 20:51 Maarten Hoogendoorn, <maarten at moretea.nl> wrote:
>
>> OK, I found a solution after taking a longer look at the bundlerEnv
>> implementation.
>> Each gem is packaged as a separate derivation (which makes complete
>> sense).
>> BundlerEnv offers the `gemConfig', in which one can set another
>> postInstall step.
>>
>> In my case, the following snippet works:
>>
>> with pkgs; (bundlerEnv {
>>     name ="ruby-protoc-v3";
>>     inherit ruby;
>>     gemfile= ./Gemfile;
>>     lockfile = ./Gemfile.lock;
>>     gemset = ./gemset.nix;
>>     gemConfig = {
>>       grpc-tools = attr: {
>>         postInstall= ''
>>           for file in $(find $out/lib/ruby/gems/2.3.0/gems/
>> grpc-tools-1.0.1/bin/x86_64-linux -type f -executable ); do
>>             patchelf --set-interpreter ${stdenv.glibc}/lib/ld-linux-x86-64.so.2
>> $file
>>           done
>>         '';
>>       };
>>     };
>> })
>>
>> I think that I got confused by the fact that I did not see any symlinks
>> during my investigation. I must have missed that somewhere.
>>
>> - Maarten
>>
>> 2016-12-01 21:24 GMT+01:00 Maarten Hoogendoorn <maarten at moretea.nl>:
>>
>> Hi,
>>
>> I'm trying to build a gem that has vendored a statically compiled program
>> (that still depends on /lib64/ld-linux-x86-64.so.2).
>>
>> I've tried to use patchelf in the postBuild in a bundlerEnv, but it's
>> complaining about not having write permissions to $out
>>
>> I wrote a one-liner to check for .nix files that contained both the words
>> bundlerEnv and patchelf, but only the top-level/all-packages.nix matched
>> both.
>>
>> I tried to create another derivation, that pulls all file in from the
>> bundlerEnv, and then patches the elf file, but it's resulting in the same
>> error message.
>>
>> A nix-expression that reproduces this error is attached.
>>
>>
>> _______________________________________________
>> nix-dev mailing list
>> nix-dev at lists.science.uu.nl
>> http://lists.science.uu.nl/mailman/listinfo/nix-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20161202/764b131f/attachment.html>


More information about the nix-dev mailing list