summary refs log tree commit diff
path: root/mixins/firefox
diff options
context:
space:
mode:
Diffstat (limited to 'mixins/firefox')
-rw-r--r--mixins/firefox/absolute-minimum.nix107
1 files changed, 93 insertions, 14 deletions
diff --git a/mixins/firefox/absolute-minimum.nix b/mixins/firefox/absolute-minimum.nix
index 579df93..d3ebe98 100644
--- a/mixins/firefox/absolute-minimum.nix
+++ b/mixins/firefox/absolute-minimum.nix
@@ -27,20 +27,28 @@ in
       addons = cfg.firefox.profiles.${profile}.extensions;
       extensionPath = "extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
 
-      extensionsData =
-        pkgs.runCommand "extensions.json" {
+      firefoxData =
+        pkgs.runCommand "firefox-default-profile" {
           buildInputs = [
             pkgs.xvfb-run
-            pkgs.mozlz4a
-            pkgs.jq
             (pkgs.firefox.override {
-              extraPolicies.Extensions.Install = map (x: x.src.outPath) addons;
+              extraPolicies = {
+                Extensions.Install = map (x: x.src.outPath) addons;
+                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";};
+                };
+              };
             })
           ];
         } ''
           HOME=$(mktemp -d)
           export FONTCONFIG_FILE=${pkgs.makeFontsConf {fontDirectories = [pkgs.roboto];}}
-          mkdir -p $HOME/.mozilla/firefox/default
+          mkdir -p $HOME/.mozilla/firefox/
+          mkdir $out
+          ln -s $out $HOME/.mozilla/firefox/default
           cat >> $HOME/.mozilla/firefox/profiles.ini<< EOF
           [Profile0]
           Default=1
@@ -49,13 +57,31 @@ in
           Path=default
           EOF
 
-          echo user_pref\(\"browser.region.network.url\", \"\"\) > $HOME/.mozilla/firefox/default/user.js
+          echo user_pref\(\"browser.region.network.url\", \"\"\)\; > $HOME/.mozilla/firefox/default/user.js
 
-          xvfb-run firefox --screenshot about:blank
+          xvfb-run firefox --screenshot about:blank --headless
 
-          cat $HOME/.mozilla/firefox/default/extensions.json > $out
-          # mozlz4a -d $HOME/.mozilla/firefox/default/addonStartup.json.lz4 /dev/stdout | jq .\"app-profile\".addons > $out
+          # cat $HOME/.mozilla/firefox/default/extensions.json > $out
+          #
         '';
+      extensionsData = "${firefoxData}/extensions.json";
+
+      # addonStartup = builtins.fromJSON (builtins.unsafeDiscardStringContext (builtins.readFile (pkgs.runCommand "addonStartup.json" {
+      #   buildInputs = [
+      #     pkgs.mozlz4a
+      #     pkgs.jq
+      #   ];
+      # }
+      # ''
+      # mozlz4a -d ${firefoxData}/addonStartup.json.lz4 /dev/stdout | jq . > $out
+      # '')));
+
+      # decrappedAddonStartup = lib.attrsets.updateManyAttrsByPath [
+      #   {
+      #     path = ["app-builtin" "addons" "google@search.mozilla.org" "enable"];
+      #     update = old: false;
+      #   }
+      # ] addonStartup;
 
       extensionManifest = e:
         builtins.fromJSON (builtins.readFile (pkgs.runCommand "${e.addonId}-manifest.json" {buildInputs = [pkgs.p7zip];} ''
@@ -69,7 +95,7 @@ in
       home.file."${prf}/extension-settings.json".source = pkgs.emptyFile;
       home.file."${prf}/extension-settings.json.tmp".source = pkgs.emptyFile;
 
-      home.file."${prf}/search.json.mozlz4".source = pkgs.emptyFile;
+      # home.file."${prf}/search.json.mozlz4".source = pkgs.emptyFile;
       home.file."${prf}/search.json.mozlz4.tmp".source = pkgs.emptyFile;
 
       home.file."${prf}/extensions".source = lib.mkForce "${pkgs.symlinkJoin {
@@ -82,8 +108,14 @@ in
       home.file."${prf}/datareporting".source = pkgs.emptyDirectory;
       home.file."${prf}/saved-telemetry-pings".source = pkgs.emptyDirectory;
 
-      # home.file."${prf}/addonStartup.json.lz4".source = mozlz4 "addonStartup.json" {"app-profile".addons = addonStartupData;};
-      # home.file."${prf}/addonStartup.json.lz4.tmp".source = pkgs.emptyFile;
+      # home.file."${prf}/addonStartup.json.lz4".source = mozlz4 "addonStartup.json" (lib.attrsets.updateManyAttrsByPath [
+      #   {
+      #     path = ["app-builtin" "addons" "google@search.mozilla.org" "enable"];
+      #     update = old: false;
+      #   }
+      # ] addonStartup);
+      home.file."${prf}/addonStartup.json.lz4".source = pkgs.emptyFile;
+      home.file."${prf}/addonStartup.json.lz4.tmp".source = pkgs.emptyFile;
 
       home.file."${prf}/addons.json".source = pkgs.emptyFile;
       home.file."${prf}/addons.json.tmp".source = pkgs.emptyFile;
@@ -127,9 +159,38 @@ in
 
       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;
+            };
+            SearchEngines.Default = "DuckDuckGo";
+            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} = {
+          userChrome = builtins.readFile ./userChrome.css;
+          search = {
+            default = "DuckDuckGo";
+            force = true;
+          };
           extensions = with firefox-addons; [
-            # kristofferhagen-nord-theme
+            kristofferhagen-nord-theme
 
             ublock-origin
             clearurls
@@ -141,8 +202,26 @@ in
           ];
           settings = {
             "extensions.activeThemeID" = "{e410fec2-1cbd-4098-9944-e21e708418af}";
+
+            # (try to) hide crap
             "browser.search.hiddenOneOffs" = "Google,Bing,Amazon.com,eBay,Twitter,Wikipedia (en)";
+            "browser.newtabpage.activity-stream.showSponsored" = false;
+            "browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
+            "services.sync.prefs.sync.browser.newtabpage.activity-stream.showSponsored" = false;
+            "services.sync.prefs.sync.browser.newtabpage.activity-stream.showSponsoredTopSites" = false;
+            "browser.newtabpage.activity-stream.default.sites" = "";
+            "browser.urlbar.suggest.topsites" = false;
+            "browser.newtabpage.activity-stream.feeds.topsites" = false;
+
+            # disable welcome page
+            "browser.aboutwelcome.enabled" = false;
+            # disable privacy notice
+            "datareporting.policy.firstRunURL" = "";
+            # "browser.newtabpage.activity-stream.aboutHome.enabled" = false;
           };
+          # extraConfig = {
+
+          # };
         };
       };
     };