fix: don't globally enable firefox env

This commit is contained in:
Patrick 2024-10-10 19:12:47 +02:00
parent bfd2e09e5a
commit becee17cab
Signed by: patrick
GPG key ID: 451F95EFB8BECD0F

View file

@ -1,16 +1,31 @@
{
home = {
sessionVariables = {
# Firefox touch support
MOZ_USE_XINPUT2 = 1;
# Firefox Hardware render
{ 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";
MOZ_DISABLE_RDD_SANDBOX = 1;
};
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"