firefox: start killing all the per-extension options
This commit is contained in:
parent
c92fb2994f
commit
60421a1622
5 changed files with 92 additions and 54 deletions
|
@ -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 ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}))
|
||||
];
|
||||
|
||||
|
|
|
@ -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 ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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 != {}) {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue