diff --git a/users/common/programs/firefox.nix b/users/common/programs/firefox.nix index 0630fe6..3d3cb1b 100644 --- a/users/common/programs/firefox.nix +++ b/users/common/programs/firefox.nix @@ -1,16 +1,31 @@ -{ - home = { - sessionVariables = { - # Firefox touch support - MOZ_USE_XINPUT2 = 1; - # Firefox Hardware render - MOZ_WEBRENDER = 1; - LIBVA_DRIVER_NAME = "nvidia"; - NVD_BACKEND = "direct"; - MOZ_DISABLE_RDD_SANDBOX = 1; - }; +{ lib, pkgs, ... }: +let + inherit (lib) concatStringsSep escapeShellArg mapAttrsToList; + env = { + MOZ_WEBRENDER = 1; + # For a better scrolling implementation and touch support. + # Be sure to also disable "Use smooth scrolling" in about:preferences + MOZ_USE_XINPUT2 = 1; + # Required for hardware video decoding. + # See https://github.com/elFarto/nvidia-vaapi-driver?tab=readme-ov-file#firefox + MOZ_DISABLE_RDD_SANDBOX = 1; + LIBVA_DRIVER_NAME = "nvidia"; + NVD_BACKEND = "direct"; + }; + envStr = concatStringsSep " " (mapAttrsToList (n: v: "${n}=${escapeShellArg v}") env); +in +{ + programs.firefox = { + enable = true; + package = pkgs.firefox.overrideAttrs (old: { + buildCommand = + old.buildCommand + + '' + substituteInPlace $out/bin/firefox \ + --replace "exec -a" ${escapeShellArg envStr}" exec -a" + ''; + }); }; - programs.firefox.enable = true; home.persistence."/state".directories = [ ".cache/mozilla" ".mozilla"