{ lib, config, ... }: let name = "browsers"; cfg = config.nixowos.defaults.${name}; in { options.nixowos.defaults.${name} = { enable = lib.mkEnableOption name; }; config = lib.mkIf cfg.enable { programs.firefox = lib.mkDefault { policies = { ExtensionSettings = let # source: https://discourse.nixos.org/t/declare-firefox-extensions-and-settings/36265/17 extension = shortId: uuid: { name = uuid; value = { install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${shortId}/latest.xpi"; installation_mode = "normal_installed"; }; }; in builtins.listToAttrs [ (extension "ublock-origin" "uBlock0@raymondhill.net") (extension "black21" "{9b84b6b4-07c4-4b4b-ba21-394d86f6e9ee}") ]; Preferences = { "browser.newtabpage.activity-stream.feeds.wallpaperfeed".Value = false; "browser.newtabpage.activity-stream.feeds.weatherfeed".Value = false; # source: https://discourse.nixos.org/t/declare-firefox-extensions-and-settings/36265 "browser.newtabpage.activity-stream.feeds.section.topstories".Value = false; "browser.newtabpage.activity-stream.feeds.snippets".Value = false; "browser.newtabpage.activity-stream.section.highlights.includePocket".Value = false; "browser.newtabpage.activity-stream.section.highlights.includeBookmarks".Value = false; "browser.newtabpage.activity-stream.section.highlights.includeDownloads".Value = false; "browser.newtabpage.activity-stream.section.highlights.includeVisited".Value = false; "browser.newtabpage.activity-stream.showSponsored".Value = false; "browser.newtabpage.activity-stream.system.showSponsored".Value = false; "browser.newtabpage.activity-stream.showSponsoredTopSites".Value = false; "browser.newtabpage.activity-stream.showSearch".Value = false; "browser.newtabpage.activity-stream.feeds.topsites".Value = false; "browser.newtabpage.activity-stream.showWeather".Value = false; }; SearchEngines = { Add = [ # source: https://discourse.nixos.org/t/declare-firefox-extensions-and-settings/36265/33 { Alias = "@np"; IconURL = "https://nixos.org/favicon.png"; Method = "GET"; Name = "NixOS Packages"; URLTemplate = "https://search.nixos.org/packages?from=0&size=200&sort=relevance&type=packages&query={searchTerms}"; } { Alias = "@no"; IconURL = "https://nixos.org/favicon.png"; Method = "GET"; Name = "NixOS Options"; URLTemplate = "https://search.nixos.org/options?from=0&size=200&sort=relevance&type=packages&query={searchTerms}"; } ]; }; }; }; }; }