Where to call patchelf in a derivation?

I haven’t exactly got to the bottom of this, but I think that autoPatchelfHook is replacing the whole of the fixupPhase, and so my postFixup hook is never being called. I’ve got things working in a slightly different way, which I overall prefer, by adding

patchelf --add-needed libssl.so.10 $out/bin/my_executable

to the end of the installPhase. By way of explanation:

  • openssl.so.10 is the dynamic dependency that was missing when I tried to run my_executable, and which is being provided by the openssl_1_0_2 package that I tried to manually add to the rpath.
  • patchelf --add-needed just adds a dynamic dependency to the binary
  • autoPatchelfHook then realizes that this dynamic dependency is needed, and that it can be satisfied by the openssl_1_0_2 in the buildInputs. So it adds openssl_1_0_2 to the rpath.