Why is this MySQL PostInstall added to the derivation?

In the MySQL derivation, there is a postInstall that does some stuff I don’t understand:

 postInstall = ''
    moveToOutput "lib/*.a" $static
    ln -s libmysqlclient${stdenv.hostPlatform.extensions.sharedLibrary} $out/lib/libmysqlclient_r${stdenv.hostPlatform.extensions.sharedLibrary}

I’ve walked through the git blame and looked at other derivations with similar stanzas, but I can’t quite seem to understand why this is here.

What is the intention of this stanza? Why does nix need it, while something like Homebrew does not? What does it accomplish?

The first command moves the static libraries to a separate output (see the docs on multiple outputs) in order to reduce closure size (static libraries will not be needed most of the time).

Second command creates an alias for the library. We probably have some package that links against libmysqlclient_r. Looking at the blame, it is probably PHP: https://github.com/NixOS/nixpkgs/commit/1367630af0050288776a7f8948d9971abf0cda53

1 Like

Thank you! That helps explain a lot and helps me track down why this fails on Mac OS :pray: