Flake for my NixOS devices
at droid 327 lines 13 kB view raw
1{...}: { 2 lib, 3 pkgs, 4 config, 5 ... 6}: let 7 package = pkgs.firefox-devedition; 8in { 9 options.cow.firefox.enable = 10 lib.mkEnableOption "enable Firefox with customizations" 11 // { 12 default = config.cow.gdi.enable; 13 }; 14 15 config = lib.mkIf config.cow.firefox.enable { 16 cow.imperm.keep = [".mozilla"]; 17 18 programs.firefox = { 19 inherit package; 20 enable = true; 21 22 policies = { 23 DisableTelemetry = true; 24 DisableFirefoxStudies = true; 25 DisableSetDesktopBackground = true; 26 DontCheckDefaultBrowser = true; 27 AppAutoUpdate = false; 28 DNSOverHTTPS.Enabled = true; 29 ShowHomeButton = true; 30 DisplayBookmarksToolbar = "always"; 31 DisableProfileImport = true; 32 DisablePocket = true; 33 DisableFirefoxAccounts = true; 34 OfferToSaveLoginsDefault = false; 35 OverrideFirstRunPage = ""; 36 NoDefaultBookmarks = true; 37 PasswordManagerEnabled = false; 38 SearchBar = "unified"; 39 EncryptedMediaExtensions = true; 40 41 EnableTrackingProtection = { 42 Value = true; 43 Locked = true; 44 Cryptomining = true; 45 Fingerprinting = true; 46 EmailTracking = true; 47 }; 48 49 Preferences = let 50 lock = val: { 51 Value = val; 52 Status = "locked"; 53 }; 54 in { 55 # General 56 "browser.aboutConfig.showWarning" = lock false; 57 "media.eme.enabled" = lock true; # Encrypted Media Extensions (DRM) 58 "layout.css.prefers-color-scheme.content-override" = lock 0; 59 "browser.startup.page" = 3; # Restore previous session 60 "toolkit.telemetry.server" = lock ""; 61 62 # New Tab 63 "browser.newtabpage.activity-stream.showSponsored" = lock false; 64 "browser.newtabpage.activity-stream.system.showSponsored" = lock false; 65 "browser.newtabpage.activity-stream.feeds.section.topstories" = lock false; 66 "browser.newtabpage.activity-stream.feeds.topsites" = lock false; 67 "browser.newtabpage.activity-stream.showSponsoredTopSites" = lock false; 68 "browser.newtabpage.activity-stream.showWeather" = lock false; 69 "browser.newtabpage.activity-stream.system.showWeather" = lock false; 70 "browser.newtabpage.activity-stream.feeds.weatherfeed" = lock false; 71 "browser.newtabpage.activity-stream.feeds.telemetry" = lock false; 72 "browser.newtabpage.activity-stream.telemetry" = lock false; 73 "browser.newtabpage.activity-stream.telemetry.structuredIngestion.endpoint" = lock ""; 74 "browser.newtabpage.pinned" = lock []; 75 "browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts.havePinned" = lock ""; 76 "browser.urlbar.suggest.weather" = lock false; 77 "browser.urlbar.quicksuggest.scenario" = lock "offline"; 78 "browser.urlbar.suggest.quicksuggest.nonsponsored" = lock false; 79 "browser.urlbar.suggest.quicksuggest.sponsored" = lock false; 80 81 # Devtools 82 "devtools.theme" = lock "dark"; 83 "devtools.dom.enabled" = lock true; 84 "devtools.command-button-rulers.enabled" = lock true; 85 "devtools.command-button-measure.enabled" = lock true; 86 "devtools.command-button-screenshot.enabled" = lock true; 87 "devtools.toolbox.host" = lock "right"; 88 "devtools.webconsole.persistlog" = lock true; 89 "devtools.webconsole.timestampMessages" = lock true; 90 91 # Privacy 92 "dom.private-attribution.submission.enabled" = lock false; 93 "privacy.globalprivacycontrol.enabled" = lock true; 94 95 # ML 96 "browser.ml.enable" = lock false; 97 "browser.ml.linkPreview.enabled" = lock false; 98 "browser.ml.pageAssist.enabled" = lock false; 99 "browser.ml.chat.enabled" = lock false; 100 "browser.ml.chat.menu" = lock false; 101 "browser.ml.chat.page" = lock false; 102 "browser.ml.chat.shortcuts" = lock false; 103 "browser.ml.chat.sidebar" = lock false; 104 }; 105 106 Extensions.Install = 107 map (x: "https://addons.mozilla.org/firefox/downloads/latest/${x}/latest.xpi") 108 [ 109 # Appearance 110 "firefox-color" 111 "material-icons-for-github" 112 113 # Security / Privacy 114 "facebook-container" 115 116 ## Ads / Youtube 117 "ublock-origin" 118 "consent-o-matic" 119 "sponsorblock" 120 121 # Information 122 "flagfox" 123 "awesome-rss" 124 "identfavicon-quantum" 125 126 # Devtools 127 "react-devtools" 128 "open-graph-preview-and-debug" 129 "wave-accessibility-tool" 130 "styl-us" 131 132 # Misc 133 "keepassxc-browser" # integration with KeepassXC 134 ]; 135 136 ExtensionSettings."*" = { 137 default_area = "menupanel"; 138 }; 139 }; 140 profiles.dev-edition-default = { 141 extensions = { 142 force = true; 143 settings = { 144 "sponsorBlocker@ajay.app".settings.alreadyInstalled = true; 145 "uBlock0@raymondhill.net".settings.selectedFilterLists = [ 146 "ublock-filters" 147 "ublock-badware" 148 "ublock-privacy" 149 "ublock-unbreak" 150 "ublock-quick-fixes" 151 ]; 152 # Stylus 153 "{7a7a4a92-a2a0-41d1-9fd7-1e92480d612d}".settings = { 154 dbInChromeStorage = true; # required se DB is stored in state.js 155 updateOnlyEnabled = true; 156 patchCsp = true; 157 instantInject = true; 158 }; 159 }; 160 }; 161 search = { 162 force = true; 163 default = "ddg"; 164 privateDefault = "ddg"; 165 engines = let 166 mkEngineForceFavicon = aliases: queryUrl: iconUrl: { 167 definedAliases = aliases; 168 icon = iconUrl; 169 urls = [{template = queryUrl;}]; 170 }; 171 mkEngine = aliases: queryUrl: iconExt: (mkEngineForceFavicon aliases queryUrl ( 172 let 173 noPath = lib.strings.concatStrings ( 174 lib.strings.intersperse "/" (lib.lists.take 3 (lib.strings.splitString "/" queryUrl)) 175 ); 176 in "${noPath}/favicon.${iconExt}" 177 )); 178 mkModrinth = aliases: type: mkEngine aliases "https://modrinth.com/discover/${type}?q={searchTerms}" "ico"; 179 in { 180 # Dev 181 "GitHub Repos" = 182 mkEngineForceFavicon ["@gh" "@github"] 183 "https://github.com/search?type=repositories&q={searchTerms}" 184 "https://github.githubassets.com/favicons/favicon-dark.svg"; 185 "SourceGraph" = mkEngine [ 186 "@sg" 187 "@sourcegraph" 188 ] "https://sourcegraph.com/search?q={searchTerms}" "png"; 189 190 ## Web 191 "MDN Web Docs" = mkEngine [ 192 "@mdn" 193 ] "https://developer.mozilla.org/en-US/search?q={searchTerms}" "ico"; 194 "Web.Dev" = 195 mkEngineForceFavicon ["@webdev" "@lighthouse"] "https://web.dev/s/results?q={searchTerms}" 196 "https://www.gstatic.com/devrel-devsite/prod/vc7080045e84cd2ce1faf7f7a3876037748d52d088e5100df2e949d051a784791/web/images/favicon.png"; 197 "Can I Use" = mkEngineForceFavicon [ 198 "@ciu" 199 "@baseline" 200 ] "https://caniuse.com/?search={searchTerms}" "https://caniuse.com/img/favicon-128.png"; 201 "NPM" = 202 mkEngineForceFavicon ["@npm"] "https://www.npmjs.com/search?q={searchTerms}" 203 "https://static-production.npmjs.com/3dc95981de4241b35cd55fe126ab6b2c.png"; 204 "Iconify" = mkEngine [ 205 "@iconify" 206 "@icons" 207 ] "https://icon-sets.iconify.design/?query={searchTerms}" "ico"; 208 "Astro" = mkEngineForceFavicon [ 209 "@astro" 210 ] "https://a.stro.cc/{searchTerms}" "https://docs.astro.build/favicon.svg"; 211 "Porkbun" = mkEngine ["@porkbun"] "https://porkbun.com/checkout/search?q={searchTerms}" "ico"; 212 "Http.Cat" = mkEngine ["@cat" "@hcat" "@httpcat"] "https://http.cat/{searchTerms}" "ico"; 213 214 ## Rust 215 "Crates.io" = mkEngine [ 216 "@crates" 217 "@cratesio" 218 "@cargo" 219 ] "https://crates.io/search?q={searchTerms}" "ico"; 220 "Rust Docs" = 221 mkEngineForceFavicon ["@rust" "@rustdocs" "@ruststd"] 222 "https://doc.rust-lang.org/std/index.html?search={searchTerms}" 223 "https://doc.rust-lang.org/static.files/favicon-2c020d218678b618.svg"; 224 "Docsrs" = mkEngine ["@docsrs"] "https://docs.rs/releases/search?query={searchTerms}" "ico"; 225 226 ## Python 227 "PyPI" = mkEngineForceFavicon [ 228 "@pypi" 229 "@pip" 230 ] "https://pypi.org/search/?q={searchTerms}" "https://pypi.org/static/images/favicon.35549fe8.ico"; 231 232 ## .NET 233 "NuGet" = mkEngine ["@nuget"] "https://www.nuget.org/packages?q={searchTerms}" "ico"; 234 235 ## Linux Stuff 236 "Kernel Docs" = mkEngine [ 237 "@lnx" 238 "@linux" 239 "@kernel" 240 ] "https://www.kernel.org/doc/html/latest/search.html?q={searchTerms}" "ico"; 241 "Arch Wiki" = mkEngine [ 242 "@aw" 243 "@arch" 244 ] "https://wiki.archlinux.org/index.php?title=Special%3ASearch&search={searchTerms}" "ico"; 245 "Nerd Fonts" = 246 mkEngineForceFavicon ["@nf" "@nerdfonts"] "https://www.nerdfonts.com/cheat-sheet?q={searchTerms}" 247 "https://www.nerdfonts.com/assets/img/favicon.ico"; 248 249 ### Haskell 250 "Hoogle Base" = mkEngine [ 251 "@h" 252 "@hoogle" 253 ] "https://hoogle.haskell.org/?scope=package%3Abase&hoogle={searchTerms}" "png"; 254 "Hoogle All" = mkEngine [ 255 "@ha" 256 "@hoogall" 257 ] "https://hoogle.haskell.org/?hoogle={searchTerms}" "png"; 258 259 ### Nix 260 "Nix Packages" = mkEngine [ 261 "@nixpkgs" 262 ] "https://search.nixos.org/packages?channel=unstable&size=500&query={searchTerms}" "png"; 263 "NixOS Options" = mkEngine [ 264 "@nixos" 265 ] "https://search.nixos.org/options?channel=unstable&size=500&query={searchTerms}" "png"; 266 "NixOS Wiki" = mkEngine ["@nixwiki"] "https://nixos.wiki/index.php?search={searchTerms}" "png"; 267 "Home Manager Options" = 268 mkEngineForceFavicon ["@hm"] 269 "https://home-manager-options.extranix.com/?release=master&query={searchTerms}" 270 "https://home-manager-options.extranix.com/images/favicon.png"; 271 "Noogle" = mkEngine [ 272 "@noogle" 273 "@nixlib" 274 ] "https://noogle.dev/q?limit=100&term={searchTerms}" "png"; 275 "SourceGraph Nix" = 276 mkEngine ["@sgn" "@yoink"] 277 "https://sourcegraph.com/search?q=lang:Nix+-repo:NixOS/*+-repo:nix-community/*+{searchTerms}" 278 "png"; 279 "Nixpkgs Issues" = 280 mkEngineForceFavicon ["@nixissues"] 281 "https://github.com/NixOS/nixpkgs/issues?q=sort%3Aupdated-desc+is%3Aissue+is%3Aopen+{searchTerms}" 282 "https://github.githubassets.com/favicons/favicon-dark.svg"; 283 "NixVim Options" = 284 mkEngineForceFavicon ["@nixvim"] 285 "https://nix-community.github.io/nixvim/search/?option_scope=0&query={searchTerms}" 286 "https://nix-community.github.io/nixvim/search/favicon.ico"; 287 288 # Media 289 "youtube" = mkEngine ["@yt"] "https://www.youtube.com/results?search_query={searchTerms}" "ico"; 290 "Spotify" = 291 mkEngineForceFavicon ["@sp" "@spotify"] "https://open.spotify.com/search/{searchTerms}" 292 "https://open.spotifycdn.com/cdn/images/favicon16.1c487bff.png"; 293 "Netflix" = mkEngine ["@nfx"] "https://www.netflix.com/search?q={searchTerms}" "ico"; 294 "IMDb" = mkEngine ["@imdb"] "https://www.imdb.com/find?q={searchTerms}" "ico"; 295 296 # Minecraft 297 "Modrinth" = mkModrinth ["@mr"] "mods"; 298 "Modrinth Resource Packs" = mkModrinth ["@mrr"] "resourcepacks"; 299 "Modrinth Data Packs" = mkModrinth ["@mrd"] "datapacks"; 300 301 # Misc 302 "Firefox Add-ons" = mkEngine [ 303 "@addons" 304 ] "https://addons.mozilla.org/en-US/firefox/search/?q={searchTerms}" "ico"; 305 "Urban Dictionary" = mkEngine [ 306 "@ud" 307 "@urban" 308 ] "https://www.urbandictionary.com/define.php?term={searchTerms}" "ico"; 309 "Google Translate" = mkEngine [ 310 "@translate" 311 ] "https://translate.google.com/?sl=auto&tl=en&text={searchTerms}&op=translate" "ico"; 312 313 # Overrides 314 "History".metaData.alias = "@h"; 315 "Bookmarks".metaData.alias = "@b"; 316 "Tabs".metaData.alias = "@t"; 317 "bing".metaData.hidden = true; 318 "amazondotcom-us".metaData.alias = "@amz"; 319 "google".metaData.alias = "@g"; 320 "wikipedia".metaData.alias = "@w"; 321 "ddg".metaData.alias = "@ddg"; 322 }; 323 }; 324 }; 325 }; 326 }; 327}