diff --git a/hosts/common/programs/firefox/addons.nix b/hosts/common/programs/firefox/addons.nix index ffa23113b..0b5afe0a7 100644 --- a/hosts/common/programs/firefox/addons.nix +++ b/hosts/common/programs/firefox/addons.nix @@ -13,10 +13,12 @@ in # future: maybe better to have browser open all videos in mpv, and then use mpv for casting. # see e.g. `ff2mpv`, `open-in-mpv` (both are packaged in nixpkgs) package = pkgs.firefox-extensions.fx_cast; + nativeMessagingHosts = [ pkgs.fx-cast-bridge ]; enable = lib.mkDefault false; }; browserpass-extension = { package = pkgs.firefox-extensions.browserpass-extension; + nativeMessagingHosts = [ pkgs.browserpass ]; enable = lib.mkDefault true; }; bypass-paywalls-clean = { diff --git a/hosts/common/programs/firefox/default.nix b/hosts/common/programs/firefox/default.nix index 928bc4a44..23cafbd53 100644 --- a/hosts/common/programs/firefox/default.nix +++ b/hosts/common/programs/firefox/default.nix @@ -7,7 +7,6 @@ # see: https://gitlab.com/librewolf-community/settings/-/blob/master/distribution/policies.json { config, lib, pkgs, ...}: -with lib; let cfg = config.sane.programs.firefox.config; mobile-prefs = lib.optionals false pkgs.librewolf-pmos-mobile.extraPrefsFiles; @@ -36,13 +35,13 @@ let # it can be further customized via ~/.librewolf/librewolf.overrides.cfg inherit (cfg.browser) extraPrefsFiles libName; - nativeMessagingHosts = lib.optionals cfg.addons.browserpass-extension.enable [ - pkgs.browserpass - ] ++ lib.optionals cfg.addons.fxCast.enable [ - pkgs.fx-cast-bridge - ]; + nativeMessagingHosts = lib.flatten ( + lib.mapAttrsToList + (_: addonOpts: lib.optionals addonOpts.enable addonOpts.nativeMessagingHosts) + cfg.addons + ); - nixExtensions = concatMap (ext: optional ext.enable ext.package) (attrValues cfg.addons); + nixExtensions = lib.concatMap (ext: lib.optional ext.enable ext.package) (builtins.attrValues cfg.addons); }).overrideAttrs (base: { nativeBuildInputs = (base.nativeBuildInputs or []) ++ [ pkgs.copyDesktopItems @@ -112,7 +111,7 @@ in ]; sane.programs.firefox = { - configOption = mkOption { + configOption = with lib; mkOption { default = {}; type = types.submodule { options = { @@ -137,6 +136,10 @@ in package = mkOption { type = types.package; }; + nativeMessagingHosts = mkOption { + type = types.listOf types.package; + default = []; + }; enable = mkOption { type = types.bool; };