Skip to content

tupakkatapa/mozid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦊 mozid

A command-line tool and Nix library for retrieving Firefox extension IDs from Mozilla Add-ons using the official API.

This tool was inspired by the difficulty of retrieving the extension ID when non-declarative installations are blocked in Firefox, as discussed in this thread.

Usage

As a Command-Line Tool

Run directly with Nix (accepts both slugs and URLs):

# Using addon slug
nix run github:tupakkatapa/mozid -- vimium-ff

# Using full URL
nix run github:tupakkatapa/mozid -- https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/

As a Nix Library

Note: Builds using mozid require the --impure flag because extension data is fetched from Mozilla's servers during the build process.

  1. Add mozid to your flake:
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
    home-manager.url = "github:nix-community/home-manager/release-25.05";
    mozid.url = "github:tupakkatapa/mozid";
  };

  outputs = { self, nixpkgs, home-manager, ... }@inputs: {
    nixosConfigurations.yourhost = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ./configuration.nix
        home-manager.nixosModules.home-manager
        {
          home-manager.extraSpecialArgs = {
            inherit (inputs) mozid;
          };
        }
      ];
    };
  };
}
  1. Then use in your home-manager configuration:
{ pkgs, mozid, ... }:
{
  home-manager.users.youruser = {
    programs.firefox = {
      enable = true;
      package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
        extraPolicies.ExtensionSettings =
          {
            "*".installation_mode = "blocked";
          }
          // mozid.lib.mkExtensions [
            "vimium-ff"
            "ublock-origin"
            "bitwarden-password-manager"
          ];
      };
    };
  };
}
Alternative: Use getExtensionId for per-extension control
# configuration.nix
{ pkgs, mozid, ... }:
{
  home-manager.users.youruser = {
    programs.firefox = {
      enable = true;
      package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
        extraPolicies.ExtensionSettings = {
          "*".installation_mode = "blocked";

          "${mozid.lib.getExtensionId "vimium-ff"}" = {
            install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/vimium-ff/latest.xpi";
            installation_mode = "force_installed";
          };

          "${mozid.lib.getExtensionId "ublock-origin"}" = {
            install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/ublock-origin/latest.xpi";
            installation_mode = "force_installed";
          };
        };
      };
    };
  };
}

About

Retrieve Firefox add-on IDs - CLI tool and Nix library

Topics

Resources

License

Stars

Watchers

Forks