Question about Firefox module extension handling

Is it possible to create something like

programs.firefox.policies.ExtensionSettings.normal_installed.myParameter = { url = "https://addons.mozilla.org/firefox/downloads/latest/$VAR/latest.xpi"; }

So you can just do programs.firefox.policies.ExtensionSettings.normal_installed.myParameter.ublock-origin?

What do you want to do?

Create a command so if I want a plug-in, that’ll be as simple as myParameter.ublock-origin

So ideally I could

myParameter = {
ublock-origin
dark-reader
}

No, it’s not possible. Here is my config.

    ExtensionSettings = builtins.mapAttrs
        (_: v: {
          installation_mode = "normal_installed";
          install_url = "https://addons.mozilla.org/firefox/downloads/latest/${v}/latest.xpi";
        })
        {
          "{446900e4-71c2-419f-a6a7-df9c091e268b}" = "bitwarden-password-manager";
          "addon@darkreader.org" = "darkreader";
        };

You need both the id and the name.

1 Like

Can’t you reduce it to ExtensionSettings.<id>.<name> that would develop into

programs.firefox.policies.ExtensionSettings = builtins.mapAttrs
  (_: extension-name: {
    installation_mode = "normal_installed";
    install_url = "https://addons.mozilla.org/firefox/downloads/latest/${extension-name}/latest.xpi";
  })
  {
    "<extension-id>" = "<extension-name>";
  };

?

Here is a script to populate automatically IDs on your "" = "<extension-name>"; structure:

set -xv && \
cd && \
git clone https://github.com/ax-mz/firefoxExtensionID.git
chmod +x firefoxExtensionID/fei.sh && \
for i in `grep '  \"\"' /etc/nixos/configuration.nix | cut -d '"' -f 4`
do sudo sed --in-place "s/\"\"\; = \"$i\"/\"$(bash firefoxExtensionID/fei.sh $i | grep --invert-match ID\ found)\" = \"$i\"\;/g" /etc/nixos/configuration.nix | grep $i
done
set +xv

Take care of only --in-place when you’re sure about the result

It’s weird, programs.firefox.policies.ExtensionSettings doesn’t seem to install FireFox and don’t seem to install any extension aswell. Nothing seems downloaded of modified in regard of FireFox/extensions when doing rebuild switch. And even if you get FireFox with nix-shell --packages firefox, FireFox doesn’t open with more extensions than before

But with programs.firefox.enable it works fine

Yes. You need to enable it to enable it. :wink: