Pulseaudio: disabling module-role-cork

I’ve just installed NixOS on my previously Arch Linux desktop and I’m in the progress of migrating the setup. Currently have some issues with Pulseaudio.

By default, Pulseaudio loads module-role-cork which mutes audio streams (e.g. MPD) when a phone stream (e.g. Teamspeak) is active. On Arch, the line containing this module was simply commented out of /etc/pulse/default.pa, but I’m unsure how I should do it on NixOS; especially when there seems to be no option for it suitable in hardware.pulseaudio.daemon.config.

How do I unload this module?

Cheers.

Looking at my system to figure this out:

$ cat /etc/pulse/default.pa 
.include /nix/store/nvy5djzrzmm6kp07lmhpslmxxnq1s3a8-pulseaudio-11.1/etc/pulse/default.pa
$ grep role-cork /nix/store/nvy5djzrzmm6kp07lmhpslmxxnq1s3a8-pulseaudio-11.1/etc/pulse/default.pa
load-module module-role-cork

So it looks like the default config loads the config from the package, with loads module-role-cork.

Looking at NixOS Search it looks like the target is actually configurable.

So now we have a problem. We could replace the file entirely but it would mean re-writing the whole config file. One solution is to take the original file and wrap it in a derivation to grep out the module-role-cork:

{ config, pkgs }:
{
  hardware.pulseaudio.configFile = pkgs.runCommand "default.pa" {} ''
    grep -v module-role-cork ${config.hardware.pulseaudio.package}/etc/pulse/default.pa > $out
  '';
}
1 Like

That does it; thanks!

I feel like simply hardware.pulseaudio.extraConfig = "unload-module module-role-cork"; is less hacky, if inelegant.

1 Like

Nice, that is ideed a clearer and more concise solution.

I didn’t know that directive existed. Thank you.