From 6af1950f5325f2c8dafddde26d734b752d427e9b Mon Sep 17 00:00:00 2001 From: oddlama Date: Fri, 8 Sep 2023 14:30:36 +0200 Subject: [PATCH] feat: "bake-in" firefox env vars --- users/myuser/graphical/firefox.nix | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/users/myuser/graphical/firefox.nix b/users/myuser/graphical/firefox.nix index 3ccc39e..3914a0c 100644 --- a/users/myuser/graphical/firefox.nix +++ b/users/myuser/graphical/firefox.nix @@ -1,13 +1,34 @@ { - programs.firefox.enable = true; - home.sessionVariables = { + 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; - # To allow vaapi access for hardware acceleration + # 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; + programs.firefox.package = pkgs.firefox.overrideAttrs (old: { + buildCommand = + old.buildCommand + + '' + substituteInPlace $out/bin/firefox \ + --replace "exec -a" ${escapeShellArg envStr}" exec -a" + ''; + }); + + # TODO userChrome + # TODO settings if they can coexist with non declarative stuff home.persistence."/state".directories = [ "Downloads"