Since
7a2605e0f3
the pulseaudio build recipe incorporates the `wrapGAppsHook`
wrapper setup-hook if `advancedBluetoothCodecs` are enabled.
This wrapper setup-hook -- like most wrappers --
wraps binaries in `$out/bin` by first renaming them,
then placing a wrapper script where the original binary was.
Unfortunatelly, pulseaudio doesn't like its
binary moved around after installation:
It records the binaries path during installation time
e5ad31e873/meson.build (L154)
then checks the path in `/proc/self/exe` and complains
> Jun 16 19:06:48 nixosb pulseaudio[2219]: W: [.pulseaudio-wra] main.c: /proc/self/exe does not point to /nix/store/bqfyzxwpxa2ydmyvh3j32xrm4chxbj22-pulseaudio-15.0/bin/pulseaudio, cannot self execute. Are you playing games?
if they don't match
e5ad31e873/src/daemon/main.c (L577)
Somehow, this also results in a real bug:
`pacmd` fails to connect to the pulseaudio server, see
https://github.com/NixOS/nixpkgs/issues/177915
To fix this issue, the commit at hand changes the
installation directory for binaries to `$out/.bin-unwrapped`.
After the installation, `$out/bin` is created by hand and
populated with symlinks to files in `$out/.bin-unwrapped`.
`wrapGAppsHook` doesn't know or care about the `.bin-unwrapped`
directory; it just sees all the symlinks in `bin`,
renames them and places wrapper scripts beside them.
Effectively, this leaves the original
binary in `.bin-unwrapped` unchanged!
So pulseaudio will find itself still in its oritinal place,
and "users" of the package can call pulseaudio
via the wrapper script in `bin` as usual.