How to wrap firefox with apulse?

I don’t use pulseaudio. I know Firefox audio works perfectly with apulse.

How can I wrap Firefox with apulse in such a way that both the firefox command, and the firefox.desktop file use apulse transparently? (and without completely rebuilding the browser myself)

kvtb via NixOS Discourse nixos1@discoursemail.com writes:

I don’t use pulseaudio. I know Firefox audio works perfectly with apulse.

How can I wrap Firefox with apulse in such a way that both the firefox command, and the firefox.desktop file use apulse transparently? (and without completely rebuilding the browser myself)

Because of how apulse works, this should be as simple as replacing the
libpulseaudio in firefox’s wrapper with apulse, which could be achieved
e.g. by writing the following to a file firefox.nix:

{ pkgs ? import <nixpkgs> {} }:
pkgs.firefox.override { libpulseaudio = pkgs.apulse; }

and installing it with nix-env -f firefox.nix -i.

thanks for your reply.

When I execute that, I get:

error: 'wrapper' at /nix/store/7jxkwci3rfd1j7k9jizyixvk28ldzx4l-nixpkgs-20.03.1619.ab3adfe1c76/nixpkgs/pkgs/applications/n
etworking/browsers/firefox/wrapper.nix:21:5 called with unexpected argument 'libpulseaudio', at /nix/store/7jxkwci3rfd1j7k
9jizyixvk28ldzx4l-nixpkgs-20.03.1619.ab3adfe1c76/nixpkgs/lib/customisation.nix:69:16

When I change it into:

pkgs.firefox.override { cfg = { libpulseaudio = pkgs.apulse; };}

I get:

replacing old 'firefox-75.0'
installing 'firefox-75.0'

as in, nothing seems to happen??

In fact, I can do this:

pkgs.firefox.override { cfg = { libpulseaudio = pkgs.pkgsdswhateverdfslse; };}

and even that runs without error…

BTW, I just found out about ‘pressureaudio’, but now I have to figure out how to enable that. Are there examples of configurations with pressureaudio?

Oh, this one’s tricky — the wrapper unfortunately uses multiple layers of functions, which makes overriding it trickier. cfg is definitely the wrong way to go, since that’s what comes from nixpkgs config, a completely unvalidated config mechanism which I’m really not a big fan of, and the config is only used to determine which plugins and such to enable.

So maybe this one will work:

{ pkgs ? import <nixpkgs> {} }:
(pkgs.wrapFirefox.override {libpulseaudio = pkgs.apulse;}) pkgs.firefox-unwrapped {}

Good news: it executed without error
Bad news: sound did not work
Good news: replace apulse by libpressureaudio, and it works

So:

      (pkgs.wrapFirefox.override { libpulseaudio = pkgs.libpressureaudio; })
      pkgs.firefox-unwrapped { };

works!
@lheckemann Thanks!