let profile = "default"; prf = ".mozilla/firefox/${profile}"; extstorage = "${prf}/browser-extension-data"; in { config, inputs, pkgs, lib, ... }: { home-manager.users.tzlil = let # gives me access to addonId and crap firefox-addons = pkgs.callPackage (pkgs.applyPatches { src = inputs.firefox-addons; patches = [./addons-passthru.patch]; name = "firefox-addons-patched"; }) {}; addons = config.home-manager.users.tzlil.programs.firefox.profiles.${profile}.extensions; in { /* TODO figure out if you like sidebery or TST more if sidebery: figure out where options are stored so you can set colors declaratively and also tree groups also figure out how to make ctrl+e for SB not conflict with vimium, maybe will rebind to F1 figure out the search engine crap, i have them hidden but id like them removed completely, Extensions.Uninstall and SearchEngines.Remove did nothing incorporate user.js instead of hardcoding some shit myself strace -f -t -e trace=file firefox | rg -e "\"/home/tzlil/(.mozilla.*?)\"" -o */ home.file."${prf}/extension-preferences.json".text = builtins.toJSON ( # i hate myself let recursiveMerge = attrList: let f = attrPath: builtins.zipAttrsWith ( n: values: if builtins.tail values == [] then builtins.head values else if builtins.all builtins.isList values then lib.unique (builtins.concatLists values) else if builtins.all builtins.isAttrs values then f (attrPath ++ [n]) values else builtins.last values ); in f [] attrList; in recursiveMerge [ { "{3c078156-979c-498b-8990-85f7987dd929}" = { origins = [""]; permissions = ["proxy" "bookmarks" "tabHide" "clipboardWrite" "history" "downloads" ""]; }; "newtaboverride@agenedia.com" = { origins = ["https://www.soeren-hentzschel.at/*"]; permissions = []; }; } (lib.fold lib.mergeAttrs {} (map (x: {${x.passthru.addonId} = {permissions = ["internal:privateBrowsingAllowed"]; origins = [];};}) addons)) ] ); home.file."${prf}/extension-settings.json".text = builtins.toJSON { commands = {}; default_search = {}; homepageNotification = {}; # gets rid of the first time notification newTabNotification = { "newtaboverride@agenedia.com" = { initialValue = false; precedenceList = [ { enabled = true; id = "newtaboverride@agenedia.com"; installDate = 1000; value = true; } ]; }; }; prefs = { "network.networkPredictionEnabled" = { initialValue = {}; precedenceList = [ { enabled = true; id = "uBlock0@raymondhill.net"; installDate = 1000; value = false; } ]; }; "privacy.containers" = { initialValue = {}; precedenceList = [ { enabled = true; id = "CanvasBlocker@kkapsner.de"; installDate = 1000; value = "CanvasBlocker@kkapsner.de"; } ]; }; "websites.hyperlinkAuditingEnabled" = { initialValue = {}; precedenceList = [ { enabled = true; id = "uBlock0@raymondhill.net"; installDate = 1000; value = false; } ]; }; }; tabHideNotification = {}; url_overrides = { newTabURL = { initialValue = "about:newtab"; precedenceList = [ { enabled = true; id = "newtaboverride@agenedia.com"; installDate = 1000; value = "moz-extension://5ba70e66-a52e-41b3-9364-b4f0a14f3854/html/newtab.html"; } ]; }; }; version = 3; }; home.file."${extstorage}/redirector@einaregilsson.com/storage.js".text = builtins.toJSON { redirects = map ({ includePattern, redirectUrl, description, }: { appliesTo = ["main_frame"]; inherit description; disabled = false; error = null; exampleResult = ""; exampleUrl = ""; excludePattern = ""; grouped = false; inherit includePattern; patternDesc = ""; patternType = "W"; processMatches = "noProcessing"; inherit redirectUrl; }) [ { includePattern = "https://*youtube.com/watch?*v=*"; redirectUrl = "https://yewtu.be/watch?$2v=$3}"; description = "invidious"; } { includePattern = "https://*youtube.com/results?*search_query=*"; redirectUrl = "https://yewtu.be/search?$2q=$3"; description = "invidious search"; } ]; enableNotifications = false; }; home.file."${extstorage}/newtaboverride@agenedia.com/storage.js".text = builtins.toJSON { url = "https://lobste.rs"; }; programs.firefox = { enable = true; package = pkgs.firefox-wayland.override { extraPolicies = { CaptivePortal = false; DisableFirefoxStudies = true; DisablePocket = true; DisableTelemetry = true; DisableFirefoxAccounts = true; FirefoxHome = { Pocket = false; Snippets = false; }; UserMessaging = { ExtensionRecommendations = false; SkipOnboarding = true; }; OverrideFirstRunPage = ""; Extensions.Install = map (x: x.src.outPath) config.home-manager.users.tzlil.programs.firefox.profiles."default".extensions; }; }; profiles.default = { userChrome = builtins.readFile ./userChrome.css; search = { default = "DuckDuckGo"; force = true; engines = { "Nix Packages" = { urls = [ { template = "https://search.nixos.org/packages"; params = [ { name = "type"; value = "packages"; } { name = "query"; value = "{searchTerms}"; } ]; } ]; icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; definedAliases = ["!np"]; }; "Home Manager" = { urls = [ { template = "https://mipmip.github.io/home-manager-option-search/"; params = [ { name = "query"; value = "{searchTerms}"; } ]; } ]; icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; definedAliases = ["!hm"]; }; "Invidious" = { urls = [ { template = "https://yewtu.be/search"; params = [ { name = "q"; value = "{searchTerms}"; } ]; } ]; iconUpdateURL = "https://invidious.io/favicon.ico"; definedAliases = ["!yt"]; }; }; }; extraConfig = builtins.readFile ( builtins.fetchurl { url = "https://raw.githubusercontent.com/arkenfox/user.js/master/user.js"; sha256 = "sha256:1mb1l9dgb8mfl70lhwykgfphqnxxi1xw0h3hlgj8jyj6n1mn5v8f"; } ); settings = { # for custom browser style "toolkit.legacyUserProfileCustomizations.stylesheets" = true; "browser.newtabpage.pinned" = [ {url = "https://tzlil.net";} ]; "browser.startup.homepage" = "https://lobste.rs"; "extensions.activeThemeID" = "{e410fec2-1cbd-4098-9944-e21e708418af}"; "svg.context-properties.content.enabled" = true; "browser.toolbars.bookmarks.visibility" = "always"; "browser.uidensity" = 1; "browser.aboutConfig.showWarning" = false; "browser.shell.checkDefaultBrowser" = false; # always private mode # its what i had with mullvad, but mayb i will not do that anymore cuz its kinda annoying having to log back into everything always # but then i also need to keep more state # "browser.privatebrowsing.autostart" = true; # remove crap "browser.newtabpage.activity-stream.improvesearch.topSiteSearchShortcuts" = false; "browser.search.hiddenOneOffs" = "Google,Bing,Amazon.com,eBay,Twitter,Wikipedia (en)"; "browser.download.dir" = config.home-manager.users.tzlil.xdg.userDirs.download; # for webconsole # "devtools.chrome.enabled" = true; # "general.config.filename" = "UserChrome.js"; # "general.config.obscure_value" = 0; # "general.config.sandbox_enabled" = false; # might be neccesary for declaratively setting newtaboverride as the default newtab # "extensions.webextensions.uuids" = { # "newtaboverride@agenedia.com" = "5ba70e66-a52e-41b3-9364-b4f0a14f3854"; # }; }; extensions = with firefox-addons; [ # privacy crap ublock-origin clearurls privacy-possum skip-redirect # localcdn canvasblocker # dont need this, impermanence # history-cleaner # usability crap darkreader vimium # upgrade for new theme stuff (firefox-addons.buildFirefoxXpiAddon { pname = "sidebery"; version = "v5.0.0rc4"; addonId = "{3c078156-979c-498b-8990-85f7987dd929}"; url = "https://github.com/mbnuqw/sidebery/releases/download/v5.0.0rc4/sidebery-5.0.0rc4.xpi"; sha256 = "sha256-YsH9yYfGefClRS93dMV/eLMFuoPFKPrx0NL2hIv4dEk="; meta = with lib; { homepage = "https://github.com/mbnuqw/sidebery"; description = "Tabs tree and bookmarks in sidebar with advanced containers configuration."; license = licenses.mit; platforms = platforms.all; }; }) redirector demodal kristofferhagen-nord-theme new-tab-override # misc snowflake ]; }; }; }; }