{ config, lib, pkgs, ... }: with lib; let userjs = pkgs.callPackage ./userjs.nix { inherit (pkgs.personal.static.userjs) arkenfox; inherit (pkgs.lib.personal) toUserJS; }; engines = import ./engines.nix { inherit lib pkgs; }; extensions = { canvasblocker = { id = "CanvasBlocker@kkapsner.de"; }; url-in-title-keepass = { id = "{fcdb71fb-c9e5-48a3-9d04-e32713f5da88}"; }; clearurls = { id = "{74145f27-f039-47ce-a470-a662b129930a}"; }; temporary-containers = { id = "{c607c8df-14a7-4f28-894f-29e8722976af}"; }; floccus = { id = "floccus@handmadeideas.org"; }; darkreader = { id = "addon@darkreader.org"; }; ublock-origin = { id = "uBlock0@raymondhill.net"; }; firefox-color = { id = "FirefoxColor@mozilla.com"; }; }; in { config = lib.mkMerge [ { stylix.targets.firefox = { colorTheme.enable = true; profileNames = [ "default" ]; }; programs.firefox = { configPath = "${config.xdg.configHome}/mozilla/firefox"; policies.ExtensionSettings = { "*".installation_mode = "blocked"; } // lib.mapAttrs' (name: value: { name = value.id; value = { install_url = "https://addons.mozilla.org/firefox/downloads/latest/${name}/latest.xpi"; installation_mode = "force_installed"; updates_disabled = true; }; }) extensions; profiles.default = { id = 0; # isDefault = true extensions = { settings."FirefoxColor@mozilla.com" = { force = true; settings.theme.colors = let mkBgColor = lib.mkForce ( with config.lib.stylix.colors; { r = base00-rgb-r; g = base00-rgb-g; b = base00-rgb-b; } ); in { frame = mkBgColor; sidebar_border = mkBgColor; popup_border = mkBgColor; tab_baground_separator = mkBgColor; tab_line = mkBgColor; toolbar_field_border_focus = mkBgColor; }; }; }; search = { force = lib.mkDefault true; engines = with engines; disableDefault // { inherit Searx; } // lib.optionalAttrs config.personal.identities.personal personal // lib.optionalAttrs config.personal.identities.work work // lib.optionalAttrs config.personal.profiles.dev dev; default = "Searx"; order = [ "Searx" "Wikipedia" ]; }; extraConfig = userjs.default; }; }; } (lib.mkIf config.programs.firefox.enable { home.shellAliases.fftmp = "firefox --profile $(mktemp -d)"; home.sessionVariables.BROWSER = "firefox"; }) ]; }