summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mixins/firefox/addons-passthru.patch16
-rw-r--r--mixins/firefox/default.nix293
2 files changed, 210 insertions, 99 deletions
diff --git a/mixins/firefox/addons-passthru.patch b/mixins/firefox/addons-passthru.patch
new file mode 100644
index 0000000..6bd149d
--- /dev/null
+++ b/mixins/firefox/addons-passthru.patch
@@ -0,0 +1,16 @@
+diff --git a/default.nix b/default.nix
+index 3098b10..806d05c 100644
+--- a/default.nix
++++ b/default.nix
+@@ -14,6 +14,11 @@ let
+ 
+       preferLocalBuild = true;
+       allowSubstitutes = true;
++      passthru = {
++       inherit addonId;
++       inherit pname;
++       inherit version;
++      };
+ 
+       buildCommand = ''
+         dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
\ No newline at end of file
diff --git a/mixins/firefox/default.nix b/mixins/firefox/default.nix
index ff14efc..754752d 100644
--- a/mixins/firefox/default.nix
+++ b/mixins/firefox/default.nix
@@ -1,5 +1,7 @@
 let
   profile = "default";
+  prf = ".mozilla/firefox/${profile}";
+  extstorage = "${prf}/browser-extension-data";
 in
   {
     config,
@@ -8,7 +10,15 @@ in
     lib,
     ...
   }: {
-    home-manager.users.tzlil = {
+    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
@@ -16,8 +26,116 @@ in
       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.".mozilla/firefox/default/browser-extension-data/redirector@einaregilsson.com/storage.js".text = builtins.toJSON {
+      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 = ["<all_urls>"];
+                permissions = ["proxy" "bookmarks" "tabHide" "clipboardWrite" "history" "downloads" "<all_urls>"];
+              };
+
+              "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,
@@ -51,21 +169,33 @@ in
           ];
         enableNotifications = false;
       };
+      home.file."${extstorage}/newtaboverride@agenedia.com/storage.js".text = builtins.toJSON {
+        url = "https://lobste.rs";
+      };
+
       programs.firefox = {
         enable = true;
-        package = pkgs.wrapFirefox pkgs.firefox-unwrapped {
+        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;
-            ExtensionSettings = {
-              "google@search.mozilla.org" = {installation_mode = "blocked";};
-              "amazondotcom@search.mozilla.org" = {installation_mode = "blocked";};
-              "wikipedia@search.mozilla.org" = {installation_mode = "blocked";};
-              "bing@search.mozilla.org" = {installation_mode = "blocked";};
-            };
           };
         };
-        profiles."${profile}" = {
+        profiles.default = {
+          userChrome = builtins.readFile ./userChrome.css;
           search = {
             default = "DuckDuckGo";
             force = true;
@@ -124,22 +254,69 @@ in
               };
             };
           };
-          userChrome = builtins.readFile ./userChrome.css;
-          extensions = with inputs.firefox-addons.packages.${pkgs.system}; [
+
+          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
-            darkreader
             privacy-possum
-            smart-referer
+            skip-redirect
             # localcdn
             canvasblocker
-            history-cleaner
+
+            # dont need this, impermanence
+            # history-cleaner
 
             # usability crap
+            darkreader
             vimium
             # upgrade for new theme stuff
-            (inputs.firefox-addons.lib.${pkgs.system}.buildFirefoxXpiAddon {
+            (firefox-addons.buildFirefoxXpiAddon {
               pname = "sidebery";
               version = "v5.0.0rc4";
               addonId = "{3c078156-979c-498b-8990-85f7987dd929}";
@@ -155,93 +332,11 @@ in
             redirector
             demodal
             kristofferhagen-nord-theme
-            # new-tab-override
+            new-tab-override
 
             # misc
             snowflake
-            # (flagfox.overrideAttrs {meta.license.free = true;})
           ];
-          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;
-
-            # remove google
-            "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;
-            # privacy crap
-            "app.normandy.enabled" = false;
-            "app.shield.optoutstudies.enabled" = false;
-            "app.update.auto" = false;
-            "beacon.enabled" = false;
-            "breakpad.reportURL" = "";
-            "browser.tabs.inTitlebar" = 0;
-            "browser.compactmode.show" = true;
-            "browser.contentblocking.category" = "strict";
-            "browser.crashReports.unsubmittedCheck.enabled" = false;
-            "browser.discovery.enabled" = false;
-            "browser.newtab.preload" = false;
-            "browser.newtabpage.activity-stream.enabled" = false;
-            "browser.newtabpage.activity-stream.feeds.section.topstories" = false;
-            "browser.newtabpage.activity-stream.telemetry" = false;
-            "browser.ping-centre.telemetry" = false;
-            "browser.pocket.enabled" = false;
-            "browser.safebrowsing.malware.enabled" = true;
-            "browser.safebrowsing.phishing.enabled" = true;
-            "browser.send_pings" = false;
-            "browser.tabs.crashReporting.sendReport" = false;
-            "signon.autofillForms" = false;
-            "media.autoplay.default" = 2;
-            "device.sensors.enabled" = false;
-            "datareporting.healthreport.service.enabled" = false;
-            "datareporting.healthreport.uploadEnabled" = false;
-            "datareporting.policy.dataSubmissionEnabled" = false;
-            "dom.security.https_only_mode" = true;
-            "dom.battery.enabled" = false;
-            "experiments.enabled" = false;
-            "experiments.supported" = false;
-            "extensions.pocket.enabled" = false;
-            "extensions.shield-recipe-client.enabled" = false;
-            "network.dns.blockDotOnion" = true;
-            "network.stricttransportsecurity.preloadlist" = true;
-            "privacy.donottrackheader.enabled" = true;
-            "privacy.firstparty.isolate" = true;
-            "privacy.trackingprotection.cryptomining.enabled" = true;
-            "privacy.trackingprotection.enabled" = true;
-            "privacy.trackingprotection.fingerprinting.enabled" = true;
-            "privacy.trackingprotection.pbmode.enabled" = true;
-            "privacy.trackingprotection.socialtracking.enabled" = true;
-            "security.insecure_password.ui.enabled" = true;
-            "security.ssl.errorReporting.automatic" = false;
-            "services.sync.engine.addons" = false;
-            "services.sync.addons.ignoreUserEnabledChanges" = true;
-            "toolkit.telemetry.archive.enabled" = false;
-            "toolkit.telemetry.bhrPing.enabled" = false;
-            "toolkit.telemetry.enabled" = false;
-            "toolkit.telemetry.firstShutdownPing.enabled" = false;
-            "toolkit.telemetry.hybridContent.enabled" = false;
-            "toolkit.telemetry.newProfilePing.enabled" = false;
-            "toolkit.telemetry.reportingpolicy.firstRun" = false;
-            "toolkit.telemetry.server" = "";
-            "toolkit.telemetry.shutdownPingSender.enabled" = false;
-            "toolkit.telemetry.unified" = false;
-            "toolkit.telemetry.updatePing.enabled" = false;
-          };
         };
       };
     };