lol

Merge pull request #262623 from K900/continued-firefox-cleanups

firefox: start killing all the per-extension options

authored by

K900 and committed by
GitHub
a52abd4c 6d502084

+106 -70
+1 -1
nixos/modules/programs/browserpass.nix
··· 27 27 "opt/brave/native-messaging-hosts/${appId}".source = source "hosts/chromium"; 28 28 "opt/brave/policies/managed/${appId}".source = source "policies/chromium"; 29 29 }; 30 - programs.firefox.wrapperConfig.enableBrowserpass = true; 30 + programs.firefox.nativeMessagingHosts.packages = [ pkgs.browserpass ]; 31 31 }; 32 32 }
+65 -38
nixos/modules/programs/firefox.nix
··· 5 5 let 6 6 cfg = config.programs.firefox; 7 7 8 - nmh = cfg.nativeMessagingHosts; 9 - 10 8 policyFormat = pkgs.formats.json { }; 11 9 12 10 organisationInfo = '' ··· 17 15 given control of your browser, unless of course they also control your 18 16 NixOS configuration. 19 17 ''; 18 + 19 + # deprecated per-native-messaging-host options 20 + nmhOptions = { 21 + browserpass = { 22 + name = "Browserpass"; 23 + package = pkgs.browserpass; 24 + }; 25 + bukubrow = { 26 + name = "Bukubrow"; 27 + package = pkgs.bukubrow; 28 + }; 29 + euwebid = { 30 + name = "Web eID"; 31 + package = pkgs.web-eid-app; 32 + }; 33 + ff2mpv = { 34 + name = "ff2mpv"; 35 + package = pkgs.ff2mpv; 36 + }; 37 + fxCast = { 38 + name = "fx_cast"; 39 + package = pkgs.fx-cast-bridge; 40 + }; 41 + gsconnect = { 42 + name = "GSConnect"; 43 + package = pkgs.gnomeExtensions.gsconnect; 44 + }; 45 + jabref = { 46 + name = "JabRef"; 47 + package = pkgs.jabref; 48 + }; 49 + passff = { 50 + name = "PassFF"; 51 + package = pkgs.passff-host; 52 + }; 53 + tridactyl = { 54 + name = "Tridactyl"; 55 + package = pkgs.tridactyl-native; 56 + }; 57 + ugetIntegrator = { 58 + name = "Uget Integrator"; 59 + package = pkgs.uget-integrator; 60 + }; 61 + }; 20 62 in 21 63 { 22 64 options.programs.firefox = { ··· 204 246 ''; 205 247 }; 206 248 207 - nativeMessagingHosts = mapAttrs (_: v: mkEnableOption (mdDoc v)) { 208 - browserpass = "Browserpass support"; 209 - bukubrow = "Bukubrow support"; 210 - euwebid = "Web eID support"; 211 - ff2mpv = "ff2mpv support"; 212 - fxCast = "fx_cast support"; 213 - gsconnect = "GSConnect support"; 214 - jabref = "JabRef support"; 215 - passff = "PassFF support"; 216 - tridactyl = "Tridactyl support"; 217 - ugetIntegrator = "Uget Integrator support"; 218 - }; 249 + nativeMessagingHosts = ({ 250 + packages = mkOption { 251 + type = types.listOf types.package; 252 + default = []; 253 + description = mdDoc '' 254 + Additional packages containing native messaging hosts that should be made available to Firefox extensions. 255 + ''; 256 + }; 257 + }) // (mapAttrs (k: v: mkEnableOption (mdDoc "${v.name} support")) nmhOptions); 219 258 }; 220 259 221 - config = mkIf cfg.enable { 260 + config = let 261 + forEachEnabledNmh = fn: flatten (mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions); 262 + in mkIf cfg.enable { 263 + warnings = forEachEnabledNmh (k: v: 264 + "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " + 265 + "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead." 266 + ); 267 + programs.firefox.nativeMessagingHosts.packages = forEachEnabledNmh (_: v: v.package); 268 + 222 269 environment.systemPackages = [ 223 270 (cfg.package.override (old: { 224 - extraPrefs = cfg.autoConfig; 225 - extraNativeMessagingHosts = 226 - old.extraNativeMessagingHosts or [] 227 - ++ optional nmh.ff2mpv pkgs.ff2mpv 228 - ++ optional nmh.euwebid pkgs.web-eid-app 229 - ++ optional nmh.gsconnect pkgs.gnomeExtensions.gsconnect 230 - ++ optional nmh.jabref pkgs.jabref 231 - ++ optional nmh.passff pkgs.passff-host; 232 - cfg = let 233 - # copy-pasted from the wrapper; TODO: figure out fix 234 - applicationName = cfg.package.binaryName or (lib.getName cfg.package); 235 - 236 - oldCfg = old.cfg or {}; 237 - nixpkgsConfig = pkgs.config.${applicationName} or {}; 238 - optionConfig = cfg.wrapperConfig; 239 - nmhConfig = { 240 - enableBrowserpass = nmh.browserpass; 241 - enableBukubrow = nmh.bukubrow; 242 - enableTridactylNative = nmh.tridactyl; 243 - enableUgetIntegrator = nmh.ugetIntegrator; 244 - enableFXCastBridge = nmh.fxCast; 245 - }; 246 - in oldCfg // nixpkgsConfig // optionConfig // nmhConfig; 271 + extraPrefsFiles = old.extraPrefsFiles or [] ++ [(pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig)]; 272 + nativeMessagingHosts = old.nativeMessagingHosts or [] ++ cfg.nativeMessagingHosts.packages; 273 + cfg = (old.cfg or {}) // cfg.wrapperConfig; 247 274 })) 248 275 ]; 249 276
+1 -1
nixos/modules/services/desktops/gnome/gnome-browser-connector.nix
··· 42 42 43 43 services.dbus.packages = [ pkgs.gnome-browser-connector ]; 44 44 45 - programs.firefox.wrapperConfig.enableGnomeExtensions = true; 45 + programs.firefox.nativeMessagingHosts.packages = [ pkgs.gnome-browser-connector ]; 46 46 }; 47 47 }
+1 -1
nixos/modules/services/x11/desktop-managers/plasma5.nix
··· 379 379 # Update the start menu for each user that is currently logged in 380 380 system.userActivationScripts.plasmaSetup = activationScript; 381 381 382 - programs.firefox.wrapperConfig.enablePlasmaBrowserIntegration = true; 382 + programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma5Packages.plasma-browser-integration ]; 383 383 }) 384 384 385 385 (mkIf (cfg.kwinrc != {}) {
+14 -16
nixos/tests/firefox.nix
··· 1 1 import ./make-test-python.nix ({ pkgs, firefoxPackage, ... }: 2 - let firefoxPackage' = firefoxPackage.override (args: { 3 - extraPrefsFiles = (args.extraPrefsFiles or []) ++ [ 4 - # make sure that autoplay is enabled by default for the audio test 5 - (builtins.toString (builtins.toFile "autoplay-pref.js" ''defaultPref("media.autoplay.default",0);'')) 6 - ]; 7 - }); 2 + { 3 + name = firefoxPackage.pname; 8 4 9 - in 10 - { 11 - name = firefoxPackage'.unwrapped.pname; 12 5 meta = with pkgs.lib.maintainers; { 13 6 maintainers = [ eelco shlevy ]; 14 7 }; ··· 17 10 { pkgs, ... }: 18 11 19 12 { imports = [ ./common/x11.nix ]; 20 - environment.systemPackages = [ 21 - firefoxPackage' 22 - pkgs.xdotool 23 - ]; 13 + environment.systemPackages = [ pkgs.xdotool ]; 14 + 15 + programs.firefox = { 16 + enable = true; 17 + preferences."media.autoplay.default" = 0; 18 + package = firefoxPackage; 19 + }; 24 20 25 21 # Create a virtual sound device, with mixing 26 22 # and all, for recording audio. ··· 58 54 59 55 }; 60 56 61 - testScript = '' 57 + testScript = let 58 + exe = firefoxPackage.unwrapped.binaryName; 59 + in '' 62 60 from contextlib import contextmanager 63 61 64 62 ··· 97 95 98 96 with subtest("Wait until Firefox has finished loading the Valgrind docs page"): 99 97 machine.execute( 100 - "xterm -e '${firefoxPackage'.unwrapped.binaryName} file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' >&2 &" 98 + "xterm -e '${exe} file://${pkgs.valgrind.doc}/share/doc/valgrind/html/index.html' >&2 &" 101 99 ) 102 100 machine.wait_for_window("Valgrind") 103 101 machine.sleep(40) ··· 105 103 with subtest("Check whether Firefox can play sound"): 106 104 with record_audio(machine): 107 105 machine.succeed( 108 - "${firefoxPackage'.unwrapped.binaryName} file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &" 106 + "${exe} file://${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/phone-incoming-call.oga >&2 &" 109 107 ) 110 108 wait_for_sound(machine) 111 109 machine.copy_from_vm("/tmp/record.wav")
+24 -13
pkgs/applications/networking/browsers/firefox/wrapper.nix
··· 34 34 , nameSuffix ? "" 35 35 , icon ? applicationName 36 36 , wmClass ? applicationName 37 + , nativeMessagingHosts ? [] 37 38 , extraNativeMessagingHosts ? [] 38 39 , pkcs11Modules ? [] 39 40 , useGlvnd ? true ··· 62 63 # PCSC-Lite daemon (services.pcscd) also must be enabled for firefox to access smartcards 63 64 smartcardSupport = cfg.smartcardSupport or false; 64 65 65 - nativeMessagingHosts = 66 - [ ] 67 - ++ lib.optional (cfg.enableBrowserpass or false) (lib.getBin browserpass) 68 - ++ lib.optional (cfg.enableBukubrow or false) bukubrow 69 - ++ lib.optional (cfg.enableTridactylNative or false) tridactyl-native 70 - ++ lib.optional (cfg.enableGnomeExtensions or false) gnome-browser-connector 71 - ++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator 72 - ++ lib.optional (cfg.enablePlasmaBrowserIntegration or false) plasma5Packages.plasma-browser-integration 73 - ++ lib.optional (cfg.enableFXCastBridge or false) fx-cast-bridge 74 - ++ lib.optional (cfg.enableKeePassXC or false) keepassxc 75 - ++ extraNativeMessagingHosts 76 - ; 66 + deprecatedNativeMessagingHost = option: pkg: 67 + if (cfg.${option} or false) 68 + then 69 + lib.warn "The cfg.${option} argument for `firefox.override` is deprecated, please add `pkgs.${pkg.pname}` to `nativeMessagingHosts` instead" 70 + [pkg] 71 + else []; 72 + 73 + allNativeMessagingHosts = builtins.map lib.getBin ( 74 + nativeMessagingHosts 75 + ++ deprecatedNativeMessagingHost "enableBrowserpass" browserpass 76 + ++ deprecatedNativeMessagingHost "enableBukubrow" bukubrow 77 + ++ deprecatedNativeMessagingHost "enableTridactylNative" tridactyl-native 78 + ++ deprecatedNativeMessagingHost "enableGnomeExtensions" gnome-browser-connector 79 + ++ deprecatedNativeMessagingHost "enableUgetIntegrator" uget-integrator 80 + ++ deprecatedNativeMessagingHost "enablePlasmaBrowserIntegration" plasma5Packages.plasma-browser-integration 81 + ++ deprecatedNativeMessagingHost "enableFXCastBridge" fx-cast-bridge 82 + ++ deprecatedNativeMessagingHost "enableKeePassXC" keepassxc 83 + ++ (if extraNativeMessagingHosts != [] 84 + then lib.warn "The extraNativeMessagingHosts argument for the Firefox wrapper is deprecated, please use `nativeMessagingHosts`" extraNativeMessagingHosts 85 + else []) 86 + ); 87 + 77 88 libs = lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups pciutils ] 78 89 ++ lib.optional pipewireSupport pipewire 79 90 ++ lib.optional ffmpegSupport ffmpeg_5 ··· 338 349 install -D -t $out/share/applications $desktopItem/share/applications/* 339 350 340 351 mkdir -p $out/lib/mozilla/native-messaging-hosts 341 - for ext in ${toString nativeMessagingHosts}; do 352 + for ext in ${toString allNativeMessagingHosts}; do 342 353 ln -sLt $out/lib/mozilla/native-messaging-hosts $ext/lib/mozilla/native-messaging-hosts/* 343 354 done 344 355