From 800133566d79ba66faec6f2aca40f9e52b6a7c4d Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Tue, 5 Sep 2023 16:28:57 +0200 Subject: firefox wrapper: fix merging of policies files If multiple extraPolicies or extraPoliciesFiles are given, the JSON objects are merged using `jq` with the `a + b` operator, which simply combines all the unique keys of `a`, `b` with the duplicated keys from `b`, without recursion. This strategy is completely wrong in this case: as policy files consists of a single key, "policies", all that happens is that `b` takes over, in other words: $(jq -s '.[0] + .[1]' a b) == $(cat b) So there is no merging at all, the final policies.json file is simply the last file in the list. The `a * b` operation should be used instead, which performs the merge by recursing in each key. --- pkgs/applications/networking/browsers/firefox/wrapper.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/applications/networking/browsers/firefox/wrapper.nix') diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index e909b15f77a..12924180c25 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -362,7 +362,7 @@ let extraPoliciesFiles=(${builtins.toString extraPoliciesFiles}) for extraPoliciesFile in "''${extraPoliciesFiles[@]}"; do - jq -s '.[0] + .[1]' "$POL_PATH" $extraPoliciesFile > .tmp.json + jq -s '.[0] * .[1]' "$POL_PATH" $extraPoliciesFile > .tmp.json mv .tmp.json "$POL_PATH" done -- cgit 1.4.1 From 64b870f0e29710fd4455207089283c6d44f72e03 Mon Sep 17 00:00:00 2001 From: A1ca7raz <7345998+A1ca7raz@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:39:05 +0000 Subject: thunderbird: add libcanberra to libs to fix notification sound --- pkgs/applications/networking/browsers/firefox/wrapper.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'pkgs/applications/networking/browsers/firefox/wrapper.nix') diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 12924180c25..123d597031c 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -85,7 +85,8 @@ let ++ lib.optional jackSupport libjack2 ++ lib.optional smartcardSupport opensc ++ lib.optional (cfg.speechSynthesisSupport or false) speechd - ++ pkcs11Modules; + ++ pkcs11Modules + ++ gtk_modules; gtk_modules = [ libcanberra-gtk3 ]; launcherName = "${applicationName}${nameSuffix}"; -- cgit 1.4.1 From 1b17ed591778ffc90e0ac07ddb338d5d34aed823 Mon Sep 17 00:00:00 2001 From: Christina Sørensen Date: Sat, 7 Oct 2023 09:04:11 +0200 Subject: firefox: default to speech synthesis enabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christina Sørensen --- pkgs/applications/networking/browsers/firefox/wrapper.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/applications/networking/browsers/firefox/wrapper.nix') diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 123d597031c..6561e51d7d9 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -84,7 +84,7 @@ let ++ lib.optional sndioSupport sndio ++ lib.optional jackSupport libjack2 ++ lib.optional smartcardSupport opensc - ++ lib.optional (cfg.speechSynthesisSupport or false) speechd + ++ lib.optional (cfg.speechSynthesisSupport or true) speechd ++ pkcs11Modules ++ gtk_modules; gtk_modules = [ libcanberra-gtk3 ]; -- cgit 1.4.1 From 190ea7b09e4f24af8b8105cdf3a8e67d5b6828c0 Mon Sep 17 00:00:00 2001 From: chayleaf Date: Fri, 13 Oct 2023 04:24:16 +0700 Subject: keepassxc: add firefox native messaging host file When using a Firefox fork, upstream package relies on you entering the browser user config path manually and writes the native messaging host file to that path. It should be much more convenient to manage it in Nix. --- pkgs/applications/misc/keepassxc/default.nix | 6 ++++++ .../misc/keepassxc/firefox-native-messaging-host.json | 9 +++++++++ pkgs/applications/networking/browsers/firefox/wrapper.nix | 2 ++ 3 files changed, 17 insertions(+) create mode 100644 pkgs/applications/misc/keepassxc/firefox-native-messaging-host.json (limited to 'pkgs/applications/networking/browsers/firefox/wrapper.nix') diff --git a/pkgs/applications/misc/keepassxc/default.nix b/pkgs/applications/misc/keepassxc/default.nix index 762434ef12c..49406fc0114 100644 --- a/pkgs/applications/misc/keepassxc/default.nix +++ b/pkgs/applications/misc/keepassxc/default.nix @@ -97,6 +97,12 @@ stdenv.mkDerivation rec { wrapQtApp "$out/Applications/KeePassXC.app/Contents/MacOS/KeePassXC" ''; + # See https://github.com/keepassxreboot/keepassxc/blob/cd7a53abbbb81e468efb33eb56eefc12739969b8/src/browser/NativeMessageInstaller.cpp#L317 + postInstall = lib.optionalString withKeePassBrowser '' + mkdir -p "$out/lib/mozilla/native-messaging-hosts" + substituteAll "${./firefox-native-messaging-host.json}" "$out/lib/mozilla/native-messaging-hosts/org.keepassxc.keepassxc_browser.json" + ''; + buildInputs = [ curl botan2 diff --git a/pkgs/applications/misc/keepassxc/firefox-native-messaging-host.json b/pkgs/applications/misc/keepassxc/firefox-native-messaging-host.json new file mode 100644 index 00000000000..70f1b26041f --- /dev/null +++ b/pkgs/applications/misc/keepassxc/firefox-native-messaging-host.json @@ -0,0 +1,9 @@ +{ + "name": "org.keepassxc.keepassxc_browser", + "description": "KeePassXC integration with native messaging support", + "path": "@out@/bin/keepassxc-proxy", + "type": "stdio", + "allowed_extensions": [ + "keepassxc-browser@keepassxc.org" + ] +} diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 6561e51d7d9..28e97bcaa41 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -8,6 +8,7 @@ , browserpass, gnome-browser-connector, uget-integrator, plasma5Packages, bukubrow, pipewire , tridactyl-native , fx-cast-bridge +, keepassxc , udev , libkrb5 , libva @@ -70,6 +71,7 @@ let ++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator ++ lib.optional (cfg.enablePlasmaBrowserIntegration or false) plasma5Packages.plasma-browser-integration ++ lib.optional (cfg.enableFXCastBridge or false) fx-cast-bridge + ++ lib.optional (cfg.enableKeePassXC or false) keepassxc ++ extraNativeMessagingHosts ; libs = lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups pciutils ] -- cgit 1.4.1 From 60421a1622ac05433afcf0179ff46f937e10096c Mon Sep 17 00:00:00 2001 From: K900 Date: Sun, 22 Oct 2023 01:30:48 +0300 Subject: firefox: start killing all the per-extension options --- nixos/modules/programs/browserpass.nix | 2 +- nixos/modules/programs/firefox.nix | 103 +++++++++++++-------- .../desktops/gnome/gnome-browser-connector.nix | 2 +- .../services/x11/desktop-managers/plasma5.nix | 2 +- .../networking/browsers/firefox/wrapper.nix | 37 +++++--- 5 files changed, 92 insertions(+), 54 deletions(-) (limited to 'pkgs/applications/networking/browsers/firefox/wrapper.nix') diff --git a/nixos/modules/programs/browserpass.nix b/nixos/modules/programs/browserpass.nix index abd99056ff3..a9670a37e61 100644 --- a/nixos/modules/programs/browserpass.nix +++ b/nixos/modules/programs/browserpass.nix @@ -27,6 +27,6 @@ with lib; "opt/brave/native-messaging-hosts/${appId}".source = source "hosts/chromium"; "opt/brave/policies/managed/${appId}".source = source "policies/chromium"; }; - programs.firefox.wrapperConfig.enableBrowserpass = true; + programs.firefox.nativeMessagingHosts.packages = [ pkgs.browserpass ]; }; } diff --git a/nixos/modules/programs/firefox.nix b/nixos/modules/programs/firefox.nix index 813e0e0105f..85f47530cf5 100644 --- a/nixos/modules/programs/firefox.nix +++ b/nixos/modules/programs/firefox.nix @@ -5,8 +5,6 @@ with lib; let cfg = config.programs.firefox; - nmh = cfg.nativeMessagingHosts; - policyFormat = pkgs.formats.json { }; organisationInfo = '' @@ -17,6 +15,50 @@ let given control of your browser, unless of course they also control your NixOS configuration. ''; + + # deprecated per-native-messaging-host options + nmhOptions = { + browserpass = { + name = "Browserpass"; + package = pkgs.browserpass; + }; + bukubrow = { + name = "Bukubrow"; + package = pkgs.bukubrow; + }; + euwebid = { + name = "Web eID"; + package = pkgs.web-eid-app; + }; + ff2mpv = { + name = "ff2mpv"; + package = pkgs.ff2mpv; + }; + fxCast = { + name = "fx_cast"; + package = pkgs.fx-cast-bridge; + }; + gsconnect = { + name = "GSConnect"; + package = pkgs.gnomeExtensions.gsconnect; + }; + jabref = { + name = "JabRef"; + package = pkgs.jabref; + }; + passff = { + name = "PassFF"; + package = pkgs.passff-host; + }; + tridactyl = { + name = "Tridactyl"; + package = pkgs.tridactyl-native; + }; + ugetIntegrator = { + name = "Uget Integrator"; + package = pkgs.uget-integrator; + }; + }; in { options.programs.firefox = { @@ -204,46 +246,31 @@ in ''; }; - nativeMessagingHosts = mapAttrs (_: v: mkEnableOption (mdDoc v)) { - browserpass = "Browserpass support"; - bukubrow = "Bukubrow support"; - euwebid = "Web eID support"; - ff2mpv = "ff2mpv support"; - fxCast = "fx_cast support"; - gsconnect = "GSConnect support"; - jabref = "JabRef support"; - passff = "PassFF support"; - tridactyl = "Tridactyl support"; - ugetIntegrator = "Uget Integrator support"; - }; + nativeMessagingHosts = ({ + packages = mkOption { + type = types.listOf types.package; + default = []; + description = mdDoc '' + Additional packages containing native messaging hosts that should be made available to Firefox extensions. + ''; + }; + }) // (mapAttrs (k: v: mkEnableOption (mdDoc "${v.name} support")) nmhOptions); }; - config = mkIf cfg.enable { + config = let + forEachEnabledNmh = fn: flatten (mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions); + in mkIf cfg.enable { + warnings = forEachEnabledNmh (k: v: + "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " + + "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead." + ); + programs.firefox.nativeMessagingHosts.packages = forEachEnabledNmh (_: v: v.package); + environment.systemPackages = [ (cfg.package.override (old: { - extraPrefs = cfg.autoConfig; - extraNativeMessagingHosts = - old.extraNativeMessagingHosts or [] - ++ optional nmh.ff2mpv pkgs.ff2mpv - ++ optional nmh.euwebid pkgs.web-eid-app - ++ optional nmh.gsconnect pkgs.gnomeExtensions.gsconnect - ++ optional nmh.jabref pkgs.jabref - ++ optional nmh.passff pkgs.passff-host; - cfg = let - # copy-pasted from the wrapper; TODO: figure out fix - applicationName = cfg.package.binaryName or (lib.getName cfg.package); - - oldCfg = old.cfg or {}; - nixpkgsConfig = pkgs.config.${applicationName} or {}; - optionConfig = cfg.wrapperConfig; - nmhConfig = { - enableBrowserpass = nmh.browserpass; - enableBukubrow = nmh.bukubrow; - enableTridactylNative = nmh.tridactyl; - enableUgetIntegrator = nmh.ugetIntegrator; - enableFXCastBridge = nmh.fxCast; - }; - in oldCfg // nixpkgsConfig // optionConfig // nmhConfig; + extraPrefsFiles = old.extraPrefsFiles or [] ++ [(pkgs.writeText "firefox-autoconfig.js" cfg.autoConfig)]; + nativeMessagingHosts = old.nativeMessagingHosts or [] ++ cfg.nativeMessagingHosts.packages; + cfg = (old.cfg or {}) // cfg.wrapperConfig; })) ]; diff --git a/nixos/modules/services/desktops/gnome/gnome-browser-connector.nix b/nixos/modules/services/desktops/gnome/gnome-browser-connector.nix index d18e303891e..4f680eabbe1 100644 --- a/nixos/modules/services/desktops/gnome/gnome-browser-connector.nix +++ b/nixos/modules/services/desktops/gnome/gnome-browser-connector.nix @@ -42,6 +42,6 @@ in services.dbus.packages = [ pkgs.gnome-browser-connector ]; - programs.firefox.wrapperConfig.enableGnomeExtensions = true; + programs.firefox.nativeMessagingHosts.packages = [ pkgs.gnome-browser-connector ]; }; } diff --git a/nixos/modules/services/x11/desktop-managers/plasma5.nix b/nixos/modules/services/x11/desktop-managers/plasma5.nix index 285d0a18193..fc328704571 100644 --- a/nixos/modules/services/x11/desktop-managers/plasma5.nix +++ b/nixos/modules/services/x11/desktop-managers/plasma5.nix @@ -379,7 +379,7 @@ in # Update the start menu for each user that is currently logged in system.userActivationScripts.plasmaSetup = activationScript; - programs.firefox.wrapperConfig.enablePlasmaBrowserIntegration = true; + programs.firefox.nativeMessagingHosts.packages = [ pkgs.plasma5Packages.plasma-browser-integration ]; }) (mkIf (cfg.kwinrc != {}) { diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index 28e97bcaa41..ed1ec5692a0 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -34,6 +34,7 @@ let , nameSuffix ? "" , icon ? applicationName , wmClass ? applicationName + , nativeMessagingHosts ? [] , extraNativeMessagingHosts ? [] , pkcs11Modules ? [] , useGlvnd ? true @@ -62,18 +63,28 @@ let # PCSC-Lite daemon (services.pcscd) also must be enabled for firefox to access smartcards smartcardSupport = cfg.smartcardSupport or false; - nativeMessagingHosts = - [ ] - ++ lib.optional (cfg.enableBrowserpass or false) (lib.getBin browserpass) - ++ lib.optional (cfg.enableBukubrow or false) bukubrow - ++ lib.optional (cfg.enableTridactylNative or false) tridactyl-native - ++ lib.optional (cfg.enableGnomeExtensions or false) gnome-browser-connector - ++ lib.optional (cfg.enableUgetIntegrator or false) uget-integrator - ++ lib.optional (cfg.enablePlasmaBrowserIntegration or false) plasma5Packages.plasma-browser-integration - ++ lib.optional (cfg.enableFXCastBridge or false) fx-cast-bridge - ++ lib.optional (cfg.enableKeePassXC or false) keepassxc - ++ extraNativeMessagingHosts - ; + deprecatedNativeMessagingHost = option: pkg: + if (cfg.${option} or false) + then + lib.warn "The cfg.${option} argument for `firefox.override` is deprecated, please add `pkgs.${pkg.pname}` to `nativeMessagingHosts` instead" + [pkg] + else []; + + allNativeMessagingHosts = builtins.map lib.getBin ( + nativeMessagingHosts + ++ deprecatedNativeMessagingHost "enableBrowserpass" browserpass + ++ deprecatedNativeMessagingHost "enableBukubrow" bukubrow + ++ deprecatedNativeMessagingHost "enableTridactylNative" tridactyl-native + ++ deprecatedNativeMessagingHost "enableGnomeExtensions" gnome-browser-connector + ++ deprecatedNativeMessagingHost "enableUgetIntegrator" uget-integrator + ++ deprecatedNativeMessagingHost "enablePlasmaBrowserIntegration" plasma5Packages.plasma-browser-integration + ++ deprecatedNativeMessagingHost "enableFXCastBridge" fx-cast-bridge + ++ deprecatedNativeMessagingHost "enableKeePassXC" keepassxc + ++ (if extraNativeMessagingHosts != [] + then lib.warn "The extraNativeMessagingHosts argument for the Firefox wrapper is deprecated, please use `nativeMessagingHosts`" extraNativeMessagingHosts + else []) + ); + libs = lib.optionals stdenv.isLinux [ udev libva mesa libnotify xorg.libXScrnSaver cups pciutils ] ++ lib.optional pipewireSupport pipewire ++ lib.optional ffmpegSupport ffmpeg_5 @@ -338,7 +349,7 @@ let install -D -t $out/share/applications $desktopItem/share/applications/* mkdir -p $out/lib/mozilla/native-messaging-hosts - for ext in ${toString nativeMessagingHosts}; do + for ext in ${toString allNativeMessagingHosts}; do ln -sLt $out/lib/mozilla/native-messaging-hosts $ext/lib/mozilla/native-messaging-hosts/* done -- cgit 1.4.1 From b29304dfbfd6d9ec4a50ca19962bcedf50c22546 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 31 Oct 2023 10:19:12 +0100 Subject: wrapFirefox: update URL in comment The previous URL explains that documentation has now moved to the new one. --- pkgs/applications/networking/browsers/firefox/wrapper.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/applications/networking/browsers/firefox/wrapper.nix') diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix index ed1ec5692a0..68f547d1f95 100644 --- a/pkgs/applications/networking/browsers/firefox/wrapper.nix +++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix @@ -46,7 +46,7 @@ let , extraPrefs ? "" , extraPrefsFiles ? [] # For more information about policies visit - # https://github.com/mozilla/policy-templates#enterprisepoliciesenabled + # https://mozilla.github.io/policy-templates/ , extraPolicies ? {} , extraPoliciesFiles ? [] , libName ? browser.libName or "firefox" # Important for tor package or the like -- cgit 1.4.1