When using ALSA applications with PipeWire, alsa-lib attempts to load PipeWire libraries from the system (as defined in /etc/alsa/conf.d/49-pipewire-modules.conf
on NixOS).
This causes problems when using software from old revisions of Nixpkgs, as it is often built against an older version of glibc, and cannot load the libraries specified in the configuration file that are linked with a newer version.
e.g., GStreamer from nixos-22.11
with glibc 2.35 running on nixos-unstable
with glibc 2.38:
$ nix-shell -I nixpkgs=channel:nixos-22.11 -p gst_all_1.gstreamer gst_all_1.gst-plugins-base --run 'GST_DEBUG=alsa:2 gst-launch-1.0 audiotestsrc ! alsasink'
Setting pipeline to PAUSED ...
0:00:00.029700688 403690 0x1cdb2d0 WARN alsa pcm.c:2655:snd_pcm_open_conf: alsalib error: Either /nix/store/6kjwvx3crxsb4dgs3amxql1j8vdk6bmm-pipewire-0.3.80-lib/lib/alsa-lib/libasound_module_pcm_pipewire.so cannot be opened or _snd_pcm_pipewire_open was not defined inside
0:00:00.029732571 403690 0x1cdb2d0 WARN alsa pcm.c:2655:snd_pcm_open_conf: alsalib error: Either /nix/store/bsqxc5ah8xcak6lsscvg23zkimkw5dvw-pipewire-0.3.80-lib/lib/alsa-lib/libasound_module_pcm_pipewire.so cannot be opened or _snd_pcm_pipewire_open was not defined inside
0:00:00.029774730 403690 0x1cdb2d0 WARN alsa gstalsasink.c:874:gst_alsasink_open:<alsasink0> Error -6 (No such device or address) calling snd_pcm_open (&alsa->handle, alsa->device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)
0:00:00.029837196 403690 0x1cdb2d0 WARN alsa gstalsasink.c:889:gst_alsasink_open:<alsasink0> error: Could not open audio device for playback.
0:00:00.029849354 403690 0x1cdb2d0 WARN alsa gstalsasink.c:889:gst_alsasink_open:<alsasink0> error: Playback open error on device 'default': No such device or address
ERROR: from element /GstPipeline:pipeline0/GstAlsaSink:alsasink0: Could not open audio device for playback.
Additional debug info:
../ext/alsa/gstalsasink.c(889): gst_alsasink_open (): /GstPipeline:pipeline0/GstAlsaSink:alsasink0:
Playback open error on device 'default': No such device or address
ERROR: pipeline doesn't want to preroll.
Failed to set pipeline to PAUSED.
Setting pipeline to NULL ...
Freeing pipeline ...
Is there a way to prevent this issue from occuring? A way to wrap software to find the right ALSA libraries, or perhaps something like nixGL, but for ALSA?