Unable to install Chrome extensions

I am unable to install Chrome extensions in Chrome or Brave from the Chrome web store.

I clicked the Add button, I saw the wheel spinning, then nothing happened. The wheel continues spinning forever.

What can I do?

I am on NixOS 23.11.

I don’t know why, but now it works. :sweat_smile:

Note that you may need to re-install your extensions if they’re installed manually when upgrading / switching.
Consider declaring these extensions in your configuration.nix: https://search.nixos.org/options?channel=unstable&show=programs.chromium.extensions&size=50&sort=relevance&type=packages&query=programs.chromium

This didn’t work for Brave. I don’t see my extensions in the browser.

Not quite sure why solution in link above isn’t working - it actually didn’t work on my side as well trying to setup smth this week.

If you’re using home-manager, try that one maybe:

{
  environment.systemPackages = with pkgs; [
    chromium
  ];

  home-manager = {
    users.${USER_NAME} = {
      programs = {
        # https://nixos.wiki/wiki/Chromium
        # https://github.com/NixOS/nixpkgs/blob/2104d00501cd78958519c5e5c3d3293368d7838d/nixos/modules/programs/chromium.nix
        # https://nix-community.github.io/home-manager/options.xhtml#opt-programs.chromium.extensions
        chromium = {
          enable = true;
          package = pkgs.chromium;

          extensions = [
            # malwarebytes browser guard
            # https://chromewebstore.google.com/detail/malwarebytes-browser-guar/ihcjicgdanjaechkgeegckofjjedodee
            "ihcjicgdanjaechkgeegckofjjedodee"

            # bitwarden
            # https://chromewebstore.google.com/detail/bitwarden-password-manage/nngceckbapebfimnlniiiahkandclblb
            "nngceckbapebfimnlniiiahkandclblb"

            # ublock origin
            # https://chromewebstore.google.com/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm
            "cjpalhdlnbpafiamejdnhcphjbkeiagm"
          ];
        };
      };
    };
  };
}

I am not using Chromium, I am using Brave. It is not the same thing. I searched, and I saw no configurable available for Brave in the Nix configuration file.

Anyway, my extensions are on the user data side, so I don’t see the benefits of adding their declaration to my Nix config. The extensions are in my profile, so upgrading to a new version does not cause any issue.

Chromium and Brave are closely related. To declaratively install extensions on Brave, simply change @JimJ92120 's code to replace chromium with brave. This should fulfill all of the given criteria.

Something like:

    home-manager.users.adam.programs = {
      brave = {
        enable = true;
        package = pkgs.brave;

        extensions = [
          # malwarebytes browser guard
          "ihcjicgdanjaechkgeegckofjjedodee"

          # bitwarden
          "nngceckbapebfimnlniiiahkandclblb"

          # ublock origin
          "cjpalhdlnbpafiamejdnhcphjbkeiagm"
        ];
      };
};

I do not believe environment.systemPackages = [ pkgs.brave ]; is necessary.

I’m glad you asked; this is something I’ve been meaning to look into for some time.

NixOS and home-manager are open-source. Take advantage of it. Figuring it out was a matter of looking into home-manager/modules/programs/chromium.nix at 1a4f12ae0bda877ec4099b429cf439aad897d7e9 · nix-community/home-manager · GitHub .

Tell me if it works. I would be surprised.

1 Like

It works. If I go to Brave > Manage Extensions then click on “Details” for one of the extensions, its source is

Source
Added by a third-party

Usually the source says Chrome Web Store.

When you’re more comfortable with Nix, browse the source. It defines a function called browserModule and uses it to define several Chromium browsers, including Brave. It’s been linked here twice, so you should find it easily.

It does not work in my configuration file:

  users.users.pierre.programs = {
      brave = {
        enable = true;
        package = pkgs.brave;

        extensions = [
          # uBlock
          "epcnnfbjfcgphgdmggkamkmgojdagdnn"
        ];
      };
  };

I have this error:

error: The option users.users.pierre.programs’ does not exist.`

I don’t use Home Manager. Can I do this in my configuration file? Because I don’t see the brave option (https://search.nixos.org/options?channel=23.11&from=0&size=50&sort=relevance&type=packages&query=brave).

1 Like

As far as I know, declaratively configuring brave requires home-manager. While home-manager is extremely popular among NixOS enjoyers, it is not a component of vanilla NixOS.

If you want to get the code posted here to work, you’re going to have to install home-manager. I guarantee it’s possible.

This is why home-manager exists, among other benefits.

OK, this is fair.

But where can I find the documentation for the different options offered by Home Manager? And why would these options be different from what is available for the NixOS configuration?

1 Like

I am not 100% sure about the documentation. Perhaps someone else can chime in.

In my experience, the most reliable way to understand the options provided by home-manager is to search its source code, either on github, your text editor, or something like that.

Normally the options are accurately portrayed on websites like https://mynixos.com/ . This is the first time I’ve encountered a discrepancy. It might have to do with how this Chromium module is cleverly structured. Normally it’s more straightforward.

home-manager and NixOS share some overlap. To oversimplify the relationship between the two, your NixOS config describes an operating system while a home-manager config describes a user environment, including personal dotfiles. It’s worth noting that home-manager provides a bunch of additional options for many popular programs.

That’s all I can say with much confidence. I’m also learning.

1 Like

In my experience, the most reliable way to understand the options provided by home-manager is to search its source code, either on github, your text editor, or something like that.
Normally the options are accurately portrayed on websites like https://mynixos.com/ .

Lot of programs aren’t “well documented” or documentation isn’t up-to-date. So it often requires some good looking into source code, research, etc.
That’s kinda expected when switching to NixOS.

Checking how programs are installed VS configured, they often get installed outside the /home directory which is system relevant (e.g /etc, /bin, etc) while configuring some programs often writes into user’s /home directory are are users specific - hence home-manager name.
But that can vary from a program to another, so it’s always good to check both solutions IMO.

Since brave is based on chromium, I think it can be assumed that most configuration can be done as with chromium.

From above comment:

1 Like