Disable Wayland support in FIrefox wrapper

After my most recent NixOS update, I noticed that Firefox keeps crashing almost immediately after browsing any website. It seems to be this Firefox Wayland bug as described here: https://bugzilla.mozilla.org/show_bug.cgi?id=1898476

The workaround of disabling Wayland by launching with MOZ_ENABLE_WAYLAND=0 seems to make FIrefox stable again. I’d like to add this environment variable to my Firefox configuration, as currently I have just been testing by launching Firefox from a CLI. However, Firefox already has a fairly complex wrapper around it, and I don’t understand how to add an extra environment variable to the wrapper without reimplementing the entire wrapper.

Could anyone provide me some pointers on how to achieve this workaround? Do I do a pkg override? Another wrapper?

Try:

{
  config,
  lib,
  pkgs,
}:

{
  environment.systemPackages = [
    (pkgs.firefox.overrideAttrs (old: {
      buildCommand =
        old.buildCommand
        + ''
          substituteInPlace $out/bin/firefox --replace "exec -a" "MOZ_ENABLE_WAYLAND=0 exec -a"
        '';
    }))
  ];
}
3 Likes

You can also try:

environment.sessionVariables.MOZ_ENABLE_WAYLAND = "0";

although I believe this requires logging out and in again.

3 Likes

Thanks for both solutions! The override from @azuwis is what I had in mind, although @drakon’s solution is also very obvious in retrospect. :sweat_smile:

Hopefully the upstream bug is resolved soon!

2 Likes