NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.35k stars 13.59k forks source link

Brave Browser Extensions #96687

Open wangkev opened 4 years ago

wangkev commented 4 years ago

Project description Similar to chrome, can brave browser also support installation of extensions declaratively?

pniedzwiedzinski commented 3 years ago

Here's what I found after a bit of research.

There're a couple of ways to install extension manually:

/usr/share/chromium/extensions

// /usr/share/chromium/extensions/pjmbgaakjkbhpopmakjoedenlfdmcdgm.json
{
    "external_crx": "/usr/lib/browserpass-chromium/browserpass-chromium-3.1.1.crx",
    "external_version": "3.1.1"
}

But this won't work now: https://github.com/brave/brave-browser/issues/5761

.config/BraveSoftware/Brave-Browser/Default/Extensions

Here lives the source of every extension, but I'm not sure if just putting a new extension here will enable it. TODO

tejing1 commented 3 years ago

This isn't a full solution to the problem, and it's home-manager based instead of NixOS based, but at least for extensions that are in the chrome web store, it should be possible by a minor addition to https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix

pniedzwiedzinski commented 3 years ago

Oh well, yeah that's possible and I just got it working. Some guys are currently working to add it to home-manager (https://github.com/nix-community/home-manager/pull/1626)

On 20/12/07 10:17PM, Jeff Huffman wrote:

This isn't a full solution to the problem, and it's home-manager based instead of NixOS based, but at least for extensions that are in the chrome web store, it should be possible by a minor addition to https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/NixOS/nixpkgs/issues/96687#issuecomment-740405136

wangkev commented 3 years ago

Thanks for the suggestion @tejing1! @pniedzwiedzinski, can you share how you incorporated the pull request into your configuration? I am a nix noob.

pniedzwiedzinski commented 3 years ago

@wangkev I have not used it

But guys, I was just setting up browserpass with programs.browserpass.enable and my brave just installed the plugin!!

{ config, lib, pkgs, ... }:

with lib;

{

  options.programs.browserpass.enable = mkEnableOption "Browserpass native messaging host";

  config = mkIf config.programs.browserpass.enable {
    environment.etc = let
      appId = "com.github.browserpass.native.json";
      source = part: "${pkgs.browserpass}/lib/browserpass/${part}/${appId}";
    in {
      # chromium
      "chromium/native-messaging-hosts/${appId}".source = source "hosts/chromium";
      "chromium/policies/managed/${appId}".source = source "policies/chromium";

      # chrome
      "opt/chrome/native-messaging-hosts/${appId}".source = source "hosts/chromium";
      "opt/chrome/policies/managed/${appId}".source = source "policies/chromium";

      # vivaldi
      "opt/vivaldi/native-messaging-hosts/${appId}".source = source "hosts/chromium";
      "opt/vivaldi/policies/managed/${appId}".source = source "policies/chromium";

      # brave
      "opt/brave/native-messaging-hosts/${appId}".source = source "hosts/chromium";
      "opt/brave/policies/managed/${appId}".source = source "policies/chromium";
    };
    nixpkgs.config.firefox.enableBrowserpass = true;
  };
}

This way we could make it work!

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info