home-manager icon indicating copy to clipboard operation
home-manager copied to clipboard

Plasma browser integration extension does not work with the firefox installed by home-manager

Open poscat0x04 opened this issue 4 years ago • 25 comments

Issue description

The extension plasma-browser-integration does not work with firefox installed by home-manager but does work with the system's firefox (/run/current-system/sw/bin/firefox)(they are using the same package pkg.firefox)

Meta

Maintainer CC

Technical details

poscat0x04 avatar Nov 01 '20 14:11 poscat0x04

Temporary workaround: cp /run/current-system/sw/lib/mozilla/native-messaging-hosts/org.kde.plasma.browser_integration.json ~/.mozilla/native-messaging-hosts

f4814 avatar Nov 06 '20 16:11 f4814

That workaround works for me. I implemented it by adding this option, pulling org.kde.plasma.browser_integration.json from the integration host package:

home.file.".mozilla/native-messaging-hosts/org.kde.plasma.browser_integration.json".source = "${pkgs.plasma-browser-integration}/lib/mozilla/native-messaging-hosts/org.kde.plasma.browser_integration.json";

In my opinion, it would be reasonable to add an option to enablePlasmaIntegration, similar to enableGnomeExtensions, as the firefox wrapper in nixpkgs already supports it (but I do not know if that would already solve the problem).

CRTified avatar Nov 09 '20 08:11 CRTified

I solved this by copying the firefox module from home-manager and adding an option for an extraConfig, which gets passed to the package directly. This is what is already being done for the AdobeFlash and gnome extension options, they are just listed explicitly. You can ignore my changes involving program-name, that was just so that this module wouldn't conflict with the existing firefox module.

diff --git a/modules/programs/firefox.nix b/../dotfiles/program/firefox/module.nix
index eafeef4..91d6532 100644
--- a/modules/programs/firefox.nix
+++ b/../dotfiles/program/firefox/module.nix
@@ -3,6 +3,7 @@
 with lib;
 
 let
+  program-name = "firefox-custom";
 
   inherit (pkgs.stdenv.hostPlatform) isDarwin;
 
@@ -67,14 +66,14 @@ in
   meta.maintainers = [ maintainers.rycee ];
 
   imports = [
-    (mkRemovedOptionModule ["programs" "firefox" "enableGoogleTalk"]
+    (mkRemovedOptionModule ["programs" program-name "enableGoogleTalk"]
       "Support for this option has been removed.")
-    (mkRemovedOptionModule ["programs" "firefox" "enableIcedTea"]
+    (mkRemovedOptionModule ["programs" program-name "enableIcedTea"]
       "Support for this option has been removed.")
   ];
 
   options = {
-    programs.firefox = {
+    programs.${program-name} = {
       enable = mkEnableOption "Firefox";
 
       package = mkOption {
@@ -215,20 +207,11 @@ in
         description = "Attribute set of Firefox profiles.";
       };
 
-      enableAdobeFlash = mkOption {
-        type = types.bool;
-        default = false;
-        description = "Whether to enable the unfree Adobe Flash plugin.";
-      };
-
-      enableGnomeExtensions = mkOption {
-        type = types.bool;
-        default = false;
+      extraPackageConfig = mkOption {
+        type = types.attrsOf types.anything;
+        default = {};
         description = ''
-          Whether to enable the GNOME Shell native host connector. Note, you
-          also need to set the NixOS option
-          <literal>services.gnome3.chrome-gnome-shell.enable</literal> to
-          <literal>true</literal>.
+          Additional config options expected by the Firefox package
         '';
       };
     };
@@ -271,10 +254,7 @@ in
     home.packages =
       let
         # The configuration expected by the Firefox wrapper.
-        fcfg = {
-          enableAdobeFlash = cfg.enableAdobeFlash;
-          enableGnomeExtensions = cfg.enableGnomeExtensions;
-        };
+        fcfg = cfg.extraPackageConfig;
 
         # A bit of hackery to force a config into the wrapper.
         browserName = cfg.package.browserName

Use it by importing the new module, and setting programs.firefox-custom = { enable = true; extraPackageConfig.enablePlasmaIntegration = true; };

WhiteAbeLincoln avatar Dec 01 '20 17:12 WhiteAbeLincoln

Ideally we should open a pull request to make this a supported option. Rather than adding new options that get passed to the package wrapper, we should allow the user to pass in their own config, which allows for changes to the package without home-manager needing to be updated.

WhiteAbeLincoln avatar Dec 01 '20 17:12 WhiteAbeLincoln

This also allowed me to add the tridactyl native messenger, which is another option that's supported in the nixpkgs firefox, but not here.

WhiteAbeLincoln avatar Dec 01 '20 17:12 WhiteAbeLincoln

I personally pass arguments like so:

{
  programs.firefox.package = pkgs.firefox.override {
    cfg = {
      enableFXCastBridge = true;
      # other stuff
    };
  };
}

Note, the override does not trigger a rebuild of firefox-unwrapped, it only affects the wrapper.

Edit: supported configuration options can be found when grepping for cfg in https://github.com/NixOS/nixpkgs/blob/c8a7e4da0aac942485aad983a806840660fc9660/pkgs/applications/networking/browsers/firefox/wrapper.nix

{
  programs.firefox.package = pkgs.firefox.override {
    cfg = {
      enablePlasmaBrowserIntegration = true;
    };
  };
}

berbiche avatar Dec 01 '20 18:12 berbiche

Ah, I didn't know that was an option, I'll see if that works for me

— Abe White

On Dec 1, 2020, at 12:18, Nicolas Berbiche [email protected] wrote:

 I personally pass arguments like so:

{ programs.firefox.package = pkgs.firefox.override { cfg = { enableFXCastBridge = true; # other stuff }; }; } Note, the override does not trigger a rebuild of firefox-unwrapped, it only affects the wrapper.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

WhiteAbeLincoln avatar Dec 01 '20 22:12 WhiteAbeLincoln

@berbiche I am trying to make tridactyl-native work on my home-manager configuration using your technique, however it does not seem to be working (asking tridactyl with the :native command tells me that it is not installed).

Is this an actual fully declarative setup, or is there something that I am missing?

ambroisie avatar Apr 17 '21 16:04 ambroisie

@berbiche I am trying to make tridactyl-native work on my home-manager configuration using your technique, however it does not seem to be working (asking tridactyl with the :native command tells me that it is not installed).

Is this an actual fully declarative setup, or is there something that I am missing?

Sorry, I don't know. I would suggest opening an issue on nixpkgs since the issue seems to be with the firefok package.

berbiche avatar Apr 21 '21 05:04 berbiche

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.

Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Jul 20 '21 06:07 stale[bot]

this issue still exists

poscat0x04 avatar Jul 22 '21 01:07 poscat0x04

Thank you for your contribution! I marked this issue as stale due to inactivity. If this remains inactive for another 7 days, I will close this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

If you have nothing of substance to add, please refrain from commenting and allow the bot close the issue. Also, don't be afraid to manually close an issue, even if it holds valuable information.

Closed issues stay in the system for people to search, read, cross-reference, or even reopen--nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Oct 20 '21 01:10 stale[bot]

Still exists

poscat0x04 avatar Oct 21 '21 08:10 poscat0x04

@berbiche 's solution works for me !

ThibaultLemaire avatar Dec 24 '21 20:12 ThibaultLemaire

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Mar 24 '22 22:03 stale[bot]

I think the issue can be closed, I do not experience this issue with trydactyl-native, when using the cfg.package override method.

ambroisie avatar Mar 25 '22 09:03 ambroisie

Edit: supported configuration options can be found when grepping for cfg in NixOS/nixpkgs@c8a7e4d/pkgs/applications/networking/browsers/firefox/wrapper.nix

{
  programs.firefox.package = pkgs.firefox.override {
    cfg = {
      enablePlasmaBrowserIntegration = true;
    };
  };
}

This still needs to be implemented.

SuperSandro2000 avatar May 02 '22 20:05 SuperSandro2000

@SuperSandro2000 what do you mean?

ambroisie avatar May 03 '22 07:05 ambroisie

A home manager option to just enable this like there is for gnome.

SuperSandro2000 avatar May 03 '22 08:05 SuperSandro2000

I'm of the opinion that we can document it, point out how to find all options in nixpkgs (as package overrides are not documented in any meaningful way), but we should not write an option for each of the possible overrides, which are painful to keep in sync with nixpkgs.

ambroisie avatar May 03 '22 10:05 ambroisie

When adding:

image

Then trying to nixos-rebuild, I get:

$ sudo nixos-rebuild switch --upgrade-all --flake path:///home/pol/Code/drupol/nixos-x260/ -v
$ nix --extra-experimental-features nix-command flakes build --out-link /tmp/nixos-rebuild.iCufm5/nixos-rebuild path:///home/pol/Code/drupol/nixos-x260/#nixosConfigurations."x260".config.system.build.nixos-rebuild -v
$ exec /nix/store/kl66mgvpiqnffql0ypsxll310zczinsf-nixos-rebuild/bin/nixos-rebuild switch --upgrade-all --flake path:///home/pol/Code/drupol/nixos-x260/ -v
building the system configuration...
Building in flake mode.
$ nix --extra-experimental-features nix-command flakes build path:///home/pol/Code/drupol/nixos-x260/#nixosConfigurations."x260".config.system.build.toplevel -v --out-link /tmp/nixos-rebuild.BtNQ90/result
error: attribute 'gtk3' missing

       at /nix/store/ny7x54058ki7k1d3ny0jx5h6kw926mxv-source/pkgs/applications/networking/browsers/firefox/wrapper.nix:186:23:

          185|       nativeBuildInputs = [ makeWrapper lndir jq ];
          186|       buildInputs = [ browser.gtk3 ];
             |                       ^
          187|
(use '--show-trace' to show detailed location information)

drupol avatar May 29 '22 10:05 drupol

Adding

home.file.".mozilla/native-messaging-hosts/org.kde.plasma.browser_integration.json".source = "${pkgs.plasma-browser-integration}/lib/mozilla/native-messaging-hosts/org.kde.plasma.browser_integration.json";

Made it work ! Thanks @CRTified !

drupol avatar May 29 '22 11:05 drupol

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Aug 31 '22 01:08 stale[bot]

For posterity. and those looking for a "complete" and "purely HM" soution:

2022-09-10T00:56:04,168999909+02:00

Code paste
{config, pkgs, ...}:
{
  programs.firefox = {
    enable = true;
    package = pkgs.firefox.override {
      cfg = {
        # Set nixkgs.legacyPackages.$system.pkgs.firefox.* options:

        # Enable pass-ff extension native messaging
        extraNativeMessagingHosts = [pkgs.passff-host];
      };
    };
  };

  # Install pass-ff extension required file:
  home.file.".mozilla/native-messaging-hosts/passff.json".source = "${pkgs.passff-host}/share/passff-host/passff.json";
}

x10an14 avatar Sep 09 '22 22:09 x10an14

For posterity. and those looking for a "complete" and "purely HM" soution:

Oops - wrong GH issue thread /embarassed. Tangentially related though.

x10an14 avatar Sep 09 '22 23:09 x10an14

Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting.

If you are the original author of the issue

  • If this is resolved, please consider closing it so that the maintainers know not to focus on this.
  • If this might still be an issue, but you are not interested in promoting its resolution, please consider closing it while encouraging others to take over and reopen an issue if they care enough.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
If you are not the original author of the issue

  • If you are also experiencing this issue, please add details of your situation to help with the debugging process.
  • If you know how to solve the issue, please consider submitting a Pull Request that addresses this issue.
Memorandum on closing issues

Don't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort.

stale[bot] avatar Dec 10 '22 02:12 stale[bot]

Just for reference — since nixpkgs commit 60421a1, the enablePlasmaBrowserIntegration option has been deprecated. You should now do:

{pkgs, ...}: {
	programs.firefox.package = pkgs.firefox.override {
		cfg.nativeMessagingHosts.packages = [pkgs.plasma5Packages.plasma-browser-integration];
	};
	# ...
}

pluiedev avatar Oct 27 '23 22:10 pluiedev