From e2b0efda53b39976cd9b91b8aaf9c46e07becfc4 Mon Sep 17 00:00:00 2001 From: Adithya Nair Date: Wed, 12 Jun 2024 19:25:47 +0530 Subject: [PATCH] refactor firefox --- home/programs/default.nix | 3 +- home/programs/firefox.nix | 200 ----------------------------- home/programs/firefox/default.nix | 87 +++++++++++++ home/programs/firefox/policies.nix | 190 +++++++++++++++++++++++++++ home/programs/firefox/prefs.cfg | 10 ++ 5 files changed, 289 insertions(+), 201 deletions(-) delete mode 100644 home/programs/firefox.nix create mode 100644 home/programs/firefox/default.nix create mode 100644 home/programs/firefox/policies.nix create mode 100644 home/programs/firefox/prefs.cfg diff --git a/home/programs/default.nix b/home/programs/default.nix index d133f33..8ee4d31 100644 --- a/home/programs/default.nix +++ b/home/programs/default.nix @@ -1,12 +1,13 @@ { pkgs, ... }: { imports = [ + ./firefox + ./aria2.nix ./bat.nix ./btop.nix ./direnv.nix ./eza.nix ./files.nix - ./firefox.nix ./git.nix ./gnupg.nix ./helix.nix diff --git a/home/programs/firefox.nix b/home/programs/firefox.nix deleted file mode 100644 index a673288..0000000 --- a/home/programs/firefox.nix +++ /dev/null @@ -1,200 +0,0 @@ -_: { - programs = { - firefox = { - enable = true; - policies = { - DisableAppUpdate = true; - DisableFirefoxAccounts = true; - DisableFirefoxStudies = true; - DisableFormHistory = true; - DisablePocket = true; - DisableTelemetry = true; - DisplayBookmarksToolbar = "newtab"; - DontCheckDefaultBrowser = true; - EnableTrackingProtection = { - Value = true; - Locked = true; - Cryptomining = true; - EmailTracking = true; - Fingerprinting = true; - }; - ExtensionSettings = { - "{b743f56d-1cc1-4048-8ba6-f9c2ab7aa54d}" = { - installation_mode = "force_installed"; - install_url = "https://addons.mozilla.org/firefox/downloads/latest/dracula-dark-colorscheme/latest.xpi"; - }; - "{d634138d-c276-4fc8-924b-40a0ea21d284}" = { - installation_mode = "force_installed"; - install_url = "https://addons.mozilla.org/firefox/downloads/latest/1password-x-password-manager/latest.xpi"; - }; - "uBlock0@raymondhill.net" = { - installation_mode = "force_installed"; - install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"; - }; - "addon@darkreader.org" = { - installation_mode = "force_installed"; - install_url = "https://addons.mozilla.org/firefox/downloads/latest/darkreader/latest.xpi"; - }; - "treestyletab@piro.sakura.ne.jp" = { - installation_mode = "force_installed"; - install_url = "https://addons.mozilla.org/firefox/downloads/latest/tree-style-tab/latest.xpi"; - }; - }; - FirefoxHome = { - Search = true; - TopSites = false; - SponsoredTopSites = false; - Highlights = false; - Pocket = false; - SponsoredPocket = false; - Snippets = false; - Locked = true; - }; - FirefoxSuggest = { - WebSuggestions = false; - SponsoredSuggestions = false; - ImproveSuggest = false; - Locked = true; - }; - Homepage = { - StartPage = "previous-session"; - Locked = true; - }; - NetworkPrediction = false; - NoDefaultBookmarks = true; - OfferToSaveLogins = false; - OverrideFirstRunPage = ""; - OverridePostUpdatePage = ""; - PasswordManagerEnabled = false; - PrimaryPassword = false; - SearchSuggestEnabled = false; - UserMessaging = { - WhatsNew = false; - ExtensionRecommendations = false; - FeatureRecommendations = false; - UrlbarInterventions = false; - SkipOnboarding = true; - MoreFromMozilla = false; - Locked = true; - }; - Preferences = { - "accessibility.force_disabled" = { Value = 1; Status = "locked"; }; - "browser.aboutConfig.showWarning" = { Value = false; Status = "locked"; }; - "browser.aboutHomeSnippets.updateUrl" = { Value = ""; Status = "locked"; }; - "browser.crashReports.unsubmittedCheck.autoSubmit2" = { Value = false; Status = "locked"; }; - "browser.selfsupport.url" = { Value = ""; Status = "locked"; }; - "browser.startup.homepage_override.mstone" = { Value = "ignore"; Status = "locked"; }; - "browser.startup.homepage_override.buildID" = { Value = ""; Status = "locked"; }; - "browser.tabs.firefox-view" = { Value = false; Status = "locked"; }; - "browser.tabs.firefox-view-next" = { Value = false; Status = "locked"; }; - "browser.urlbar.suggest.history" = { Value = false; Status = "locked"; }; - "browser.urlbar.suggest.topsites" = { Value = false; Status = "locked"; }; - "dom.security.https_only_mode" = { Value = true; Status = "locked"; }; - "extensions.htmlaboutaddons.recommendations.enabled" = { Value = false; Status = "locked"; }; - "extensions.recommendations.themeRecommendationUrl" = { Value = ""; Status = "locked"; }; - "gfx.canvas.accelerated.cache-items" = { Value = 4096; Status = "locked"; }; - "gfx.canvas.accelerated.cache-size" = { Value = 512; Status = "locked"; }; - "gfx.content.skia-font-cache-size" = { Value = 20; Status = "locked"; }; - "network.dns.disablePrefetch" = { Value = false; Status = "locked"; }; - "network.dns.disablePrefetchFromHTTPS" = { Value = false; Status = "locked"; }; - "network.http.max-connections" = { Value = 1800; Status = "locked"; }; - "network.http.max-persistent-connections-per-server" = { Value = 10; Status = "locked"; }; - "network.http.max-urgent-start-excessive-connections-per-host" = { Value = 5; Status = "locked"; }; - "network.http.pacing.requests.enabled" = { Value = false; Status = "locked"; }; - "network.IDN_show_punycode" = { Value = true; Status = "locked"; }; - "network.predictor.enabled" = { Value = false; Status = "locked"; }; - "network.prefetch-next" = { Value = false; Status = "locked"; }; - "network.trr.mode" = { Value = 5; Status = "locked"; }; - "signon.management.page.breach-alerts.enabled" = { Value = false; Status = "locked"; }; - }; - }; - profiles.default = { - id = 0; - name = "Default"; - isDefault = true; - search = { - default = "DuckDuckGo"; - engines = { - "Bing".metaData.hidden = true; - "Google".metaData.hidden = true; - "Nix Packages" = { - urls = [ - { - template = "https://search.nixos.org/packages"; - params = [ - { name = "channel"; value = "unstable"; } - { name = "query"; value = "{searchTerms}"; } - ]; - } - ]; - iconUpdateURL = "https://nixos.org/favicon.png"; - definedAliases = [ "@np" ]; - }; - "NixOS Options" = { - urls = [ - { - template = "https://search.nixos.org/options"; - params = [ - { name = "channel"; value = "unstable"; } - { name = "query"; value = "{searchTerms}"; } - ]; - } - ]; - iconUpdateURL = "https://nixos.org/favicon.png"; - definedAliases = [ "@no" ]; - }; - "GitHub" = { - urls = [ - { - template = "https://github.com/search"; - params = [ - { name = "q"; value = "{searchTerms}"; } - { name = "type"; value = "repositories"; } - ]; - } - ]; - iconUpdateURL = "https://github.com/favicon.ico"; - definedAliases = [ "@gh" ]; - }; - "Docker Hub" = { - urls = [ - { - template = "https://hub.docker.com/search"; - params = [ - { name = "q"; value = "{searchTerms}"; } - ]; - } - ]; - iconUpdateURL = "https://hub.docker.com/favicon.ico"; - definedAliases = [ "@docker" ]; - }; - "YouTube" = { - urls = [ - { - template = "https://www.youtube.com/results"; - params = [ - { name = "search_query"; value = "{searchTerms}"; } - ]; - } - ]; - iconUpdateURL = "https://www.youtube.com/favicon.ico"; - definedAliases = [ "@yt" ]; - }; - }; - force = true; - }; - settings = { - "app.shield.optoutstudies.enabled" = false; - "content.notify.interval" = 100000; - "dom.events.asyncClipboard.clipboardItem" = true; - "privacy.donottrackheader.enabled" = true; - "privacy.firstparty.isolate" = true; - "privacy.globalprivacycontrol.enabled" = true; - "startup.homepage_override_url" = ""; - "startup.homepage_welcome_url" = ""; - "startup.homepage_welcome_url.additional" = ""; - }; - }; - }; - }; -} diff --git a/home/programs/firefox/default.nix b/home/programs/firefox/default.nix new file mode 100644 index 0000000..4805ac6 --- /dev/null +++ b/home/programs/firefox/default.nix @@ -0,0 +1,87 @@ +{ pkgs, ... }: { + programs = { + firefox = { + enable = true; + package = pkgs.firefox.override { + extraPolicies = import ./policies.nix; + extraPrefs = builtins.readFile ./prefs.cfg; + }; + profiles.default = { + id = 0; + name = "Default"; + isDefault = true; + search = { + default = "DuckDuckGo"; + engines = { + "Bing".metaData.hidden = true; + "Google".metaData.hidden = true; + "Nix Packages" = { + urls = [ + { + template = "https://search.nixos.org/packages"; + params = [ + { name = "channel"; value = "unstable"; } + { name = "query"; value = "{searchTerms}"; } + ]; + } + ]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "@np" ]; + }; + "NixOS Options" = { + urls = [ + { + template = "https://search.nixos.org/options"; + params = [ + { name = "channel"; value = "unstable"; } + { name = "query"; value = "{searchTerms}"; } + ]; + } + ]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = [ "@no" ]; + }; + "GitHub" = { + urls = [ + { + template = "https://github.com/search"; + params = [ + { name = "q"; value = "{searchTerms}"; } + { name = "type"; value = "repositories"; } + ]; + } + ]; + iconUpdateURL = "https://github.com/favicon.ico"; + definedAliases = [ "@gh" ]; + }; + "Docker Hub" = { + urls = [ + { + template = "https://hub.docker.com/search"; + params = [ + { name = "q"; value = "{searchTerms}"; } + ]; + } + ]; + iconUpdateURL = "https://hub.docker.com/favicon.ico"; + definedAliases = [ "@docker" ]; + }; + "YouTube" = { + urls = [ + { + template = "https://www.youtube.com/results"; + params = [ + { name = "search_query"; value = "{searchTerms}"; } + ]; + } + ]; + iconUpdateURL = "https://www.youtube.com/favicon.ico"; + definedAliases = [ "@yt" ]; + }; + }; + force = true; + }; + }; + }; + }; +} diff --git a/home/programs/firefox/policies.nix b/home/programs/firefox/policies.nix new file mode 100644 index 0000000..32aded2 --- /dev/null +++ b/home/programs/firefox/policies.nix @@ -0,0 +1,190 @@ +{ + DisableAppUpdate = true; + DisableFirefoxAccounts = true; + DisableFirefoxStudies = true; + DisableFormHistory = true; + DisablePocket = true; + DisableTelemetry = true; + DisplayBookmarksToolbar = "newtab"; + DontCheckDefaultBrowser = true; + EnableTrackingProtection = { + Value = true; + Locked = true; + Cryptomining = true; + EmailTracking = true; + Fingerprinting = true; + }; + ExtensionSettings = { + "{b743f56d-1cc1-4048-8ba6-f9c2ab7aa54d}" = { + installation_mode = "force_installed"; + install_url = "https://addons.mozilla.org/firefox/downloads/latest/dracula-dark-colorscheme/latest.xpi"; + }; + "{d634138d-c276-4fc8-924b-40a0ea21d284}" = { + installation_mode = "force_installed"; + install_url = "https://addons.mozilla.org/firefox/downloads/latest/1password-x-password-manager/latest.xpi"; + }; + "uBlock0@raymondhill.net" = { + installation_mode = "force_installed"; + install_url = "https://addons.mozilla.org/firefox/downloads/latest/ublock-origin/latest.xpi"; + }; + "addon@darkreader.org" = { + installation_mode = "force_installed"; + install_url = "https://addons.mozilla.org/firefox/downloads/latest/darkreader/latest.xpi"; + }; + "treestyletab@piro.sakura.ne.jp" = { + installation_mode = "force_installed"; + install_url = "https://addons.mozilla.org/firefox/downloads/latest/tree-style-tab/latest.xpi"; + }; + }; + FirefoxHome = { + Search = true; + TopSites = false; + SponsoredTopSites = false; + Highlights = false; + Pocket = false; + SponsoredPocket = false; + Snippets = false; + Locked = true; + }; + FirefoxSuggest = { + WebSuggestions = false; + SponsoredSuggestions = false; + ImproveSuggest = false; + Locked = true; + }; + Homepage = { + StartPage = "previous-session"; + Locked = true; + }; + NetworkPrediction = false; + NoDefaultBookmarks = true; + OfferToSaveLogins = false; + OverrideFirstRunPage = ""; + OverridePostUpdatePage = ""; + PasswordManagerEnabled = false; + PrimaryPassword = false; + SearchSuggestEnabled = false; + UserMessaging = { + WhatsNew = false; + ExtensionRecommendations = false; + FeatureRecommendations = false; + UrlbarInterventions = false; + SkipOnboarding = true; + MoreFromMozilla = false; + Locked = true; + }; + Preferences = { + "accessibility.force_disabled" = { + Value = 1; + Status = "locked"; + }; + "browser.aboutConfig.showWarning" = { + Value = false; + Status = "locked"; + }; + "browser.aboutHomeSnippets.updateUrl" = { + Value = ""; + Status = "locked"; + }; + "browser.crashReports.unsubmittedCheck.autoSubmit2" = { + Value = false; + Status = "locked"; + }; + "browser.selfsupport.url" = { + Value = ""; + Status = "locked"; + }; + "browser.startup.homepage_override.mstone" = { + Value = "ignore"; + Status = "locked"; + }; + "browser.startup.homepage_override.buildID" = { + Value = ""; + Status = "locked"; + }; + "browser.tabs.firefox-view" = { + Value = false; + Status = "locked"; + }; + "browser.tabs.firefox-view-next" = { + Value = false; + Status = "locked"; + }; + "browser.urlbar.suggest.history" = { + Value = false; + Status = "locked"; + }; + "browser.urlbar.suggest.topsites" = { + Value = false; + Status = "locked"; + }; + "dom.security.https_only_mode" = { + Value = true; + Status = "locked"; + }; + "extensions.htmlaboutaddons.recommendations.enabled" = { + Value = false; + Status = "locked"; + }; + "extensions.recommendations.themeRecommendationUrl" = { + Value = ""; + Status = "locked"; + }; + "gfx.canvas.accelerated.cache-items" = { + Value = 4096; + Status = "locked"; + }; + "gfx.canvas.accelerated.cache-size" = { + Value = 512; + Status = "locked"; + }; + "gfx.content.skia-font-cache-size" = { + Value = 20; + Status = "locked"; + }; + "network.dns.disablePrefetch" = { + Value = false; + Status = "locked"; + }; + "network.dns.disablePrefetchFromHTTPS" = { + Value = false; + Status = "locked"; + }; + "network.http.max-connections" = { + Value = 1800; + Status = "locked"; + }; + "network.http.max-persistent-connections-per-server" = { + Value = 10; + Status = "locked"; + }; + "network.http.max-urgent-start-excessive-connections-per-host" = { + Value = 5; + Status = "locked"; + }; + "network.http.pacing.requests.enabled" = { + Value = false; + Status = "locked"; + }; + "network.IDN_show_punycode" = { + Value = true; + Status = "locked"; + }; + "network.predictor.enabled" = { + Value = false; + Status = "locked"; + }; + "network.prefetch-next" = { + Value = false; + Status = "locked"; + }; + "network.trr.mode" = { + Value = 5; + Status = "locked"; + }; + "signon.management.page.breach-alerts.enabled" = { + Value = false; + Status = "locked"; + }; + }; +} diff --git a/home/programs/firefox/prefs.cfg b/home/programs/firefox/prefs.cfg new file mode 100644 index 0000000..d2cc936 --- /dev/null +++ b/home/programs/firefox/prefs.cfg @@ -0,0 +1,10 @@ +pref("app.shield.optoutstudies.enabled", false); +pref("content.notify.interval", 100000); +pref("dom.events.asyncClipboard.clipboardItem", true); +pref("privacy.donottrackheader.enabled", true); +pref("privacy.firstparty.isolate", true); +pref("privacy.globalprivacycontrol.enabled", true); +pref("startup.homepage_override_url", ""); +pref("startup.homepage_welcome_url", ""); +pref("startup.homepage_welcome_url.additional", ""); +