Pipewire is quite a beast, still very much in flux and has some changes to integration with various environments so let's track the current state of it on NixOS here.
Currently on master:
configuration.nix:
# Not strictly required but pipewire will use rtkit if it is present
security.rtkit.enable = true;
services.pipewire = {
enable = true;
# Compatibility shims, adjust according to your needs
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
Known problems:
pw-pulse %command% in launch options works around thisldd pw-pulse)From my experience
There are other things that are pretty annoying, audio control is completely bonkers for me, alsactl/alsamixer is half broken, I have to rely on using pactl and the pulseaudio library shims to even change my audio with keybinds. Anyway just a couple of things off the top of my head.
Note that you may not experience some of my issues, because it's configuration dependent on more than just the pipewire configuration.
As of November 14, 2020, all of the issues I've listed have been resolved (on my system). HFP/HSP doesn't work the last time checked that out, as only the backend support is implemented, in case that is a deal breaker for anyone (as far as I can remember).
Did some digging and the Discord issue is fairly simple: the wrapper prepends the dependencies' paths to LD_LIBRARY_PATH, and those dependencies include libpulseaudio. So I tried making a copy of the wrapper script that prepends the pipewire pulseaudio shim's path instead of the native pulseaudio one and voil脿, it works perfectly! Simply removing the libpulseaudio part from LD_LIBRARY_PATH works as well, as long as the result does not put the native libpulseaudio before the pipewire shim.
I'm guessing the Right solution to this is to wait for the pulse-bridge aka "fake" pulseaudio server in pipewire so Discord (and presumably steam) can just use the native library and everything looks like business as usual to them.
Pulse-bridge does seem to work surprisingly well: I tried stopping the pipewire service and launching it manually with pulse-bridge enabled (I have pulseaudio disabled in my nixos config so there won't be conflicts): pipewire-media-session -e pulse-bridge
If steam, discord etc is launched after starting the media session, audio is working without further tweaking as expected. If they were running before this, they will likely crash or lock up when pipewire is stopped.
So for transparent support we'll need a nixos option to enable the pulse-bridge module as described upstream. Some discussion about that happened in #102514 .
The same approach could be used for the bluez5 module which is also disabled by default for now.
Upstream has deprecated the libpulseaudio.so shim and provides a systemd service to load pulse-bridge now. This makes packaging a lot easier since we don't have to patch files and there should no longer be socket conflicts with pulseaudio either.
ALSA compatibility option doesn't provide ctl.!default for some reason: https://github.com/NixOS/nixpkgs/blob/c18b90b5b90bd20c421ffe795420ad501e6613c7/nixos/modules/services/desktops/pipewire.nix#L85-L98
This leads to the impossibility to control pipewire via alsamixer :(
Most helpful comment
Upstream has deprecated the libpulseaudio.so shim and provides a systemd service to load pulse-bridge now. This makes packaging a lot easier since we don't have to patch files and there should no longer be socket conflicts with pulseaudio either.