Code change:
<ins> { lib , pkgs , alsa-lib , plugins ? [ pkgs.alsa-plugins ] , lndir , symlinkJoin , runCommand }: let merged = symlinkJoin { name = "alsa-plugins-merged"; paths = plugins; }; in runCommand "${alsa-lib.pname}-${alsa-lib.version}" { meta = with lib; { description = "wrapper to ease access to ALSA plugins"; platforms = platforms.linux; maintainers = with maintainers; [ gm6k ]; }; outputs = alsa-lib.outputs; } ( ( lib.concatMapStringsSep "n" ( output: '' mkdir ${builtins.placeholder output} ${lndir}/bin/lndir ${lib.attrByPath [output] null alsa-lib}  ${builtins.placeholder output} '' ) alsa-lib.outputs ) + '' cp -r ${merged}/lib/alsa-lib $out/lib ( echo $out | wc -c echo ${alsa-lib} | wc -c ) | xargs echo | grep -q "^(.*) 1$" || ( echo cannot binary patch exit 1 ) rm $out/lib/libasound.la rm $out/lib/libasound.so.?.?.? rm $dev/lib/pkgconfig/alsa.pc rm $dev/nix-support/propagated-build-inputs cp ${alsa-lib}/lib/libasound.la $out/lib cp ${alsa-lib}/lib/libasound.so.?.?.? $out/lib cp ${alsa-lib.dev}/lib/pkgconfig/alsa.pc $dev/lib/pkgconfig cp ${alsa-lib.dev}/nix-support/propagated-build-inputs $dev/nix-support sed -i  $out/lib/libasound.la  $out/lib/libasound.so.?.?.?  $dev/lib/pkgconfig/alsa.pc  $dev/nix-support/propagated-build-inputs  -e "s@${alsa-lib}@$out@g" '' ) </ins>

Related discussion:
text: I get errors like: This shared object is provided by derivation, not i.e:
Just some additional info: using the wrapper script provided by doesn't solve it either.
I would like to hear from someone more experienced, but maybe an aggregate package (like for texLive) could solve this.
You are right. I was talking about the PulseAudio plugin simply because I believe that it is the only plugin used by almost everyone. Other plugins are kind of “special”, or “professional” and can be dealt with on per-expression basis, but the PulseAudio plugin should work out of the box without any extra configuration from the user or the expression maintainer.
BTW I just found this topic from 2009 with a relevant discussion: An aggregate package seems to be a viable solution. The problem with this (which seems to be the one concerning in the ML) is that adding plugins won’t be possible without rebuilds.
It's really tricky because ALSAPLUGINDIRS is a compiletime constant in alsa-lib. (so the env-var approach won't work) I tried to add a dir for plugins like for the graphics drivers to /run/alsa-plugins. The problem with this is that alsa-lib builds smixer into ALSAPLUGINDIRS so it has to be inside the derivation. You can pass the configure flag --disable-mixer an then alsa-lib will build, but then gstreamer won't build anymore (i guess it tries to link against the smixer in alsa-lib). I haven't tried the aggregate package yet because I'm not sure how to make everything use the aggregate derivation instead of the alsa-lib.
By the way, looks like should be removed. Looks like there used to be a in Nixpkgs that made respect this environment variable, but now it is .
Shouldn’t the commit that removed the “unused” variable be reverted? I mean, we need a beautiful solution, but at least it worked before that.
All the plugin so-files are relatively small in comparison to libasound (<300 kB together vs. ~1.4 MB), so we might consider having the default attribute contain the plugins needed for pulseaudio playback. Our attribute no longer needs to build, so we should be able to reverse the dependency and make depend on . /cc should know more about pulseaudio packaging. Perhaps it's a similar situation in there.