about summary refs log tree commit diff
path: root/modules/nixos/firefox/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/nixos/firefox/default.nix')
-rw-r--r--modules/nixos/firefox/default.nix279
1 files changed, 279 insertions, 0 deletions
diff --git a/modules/nixos/firefox/default.nix b/modules/nixos/firefox/default.nix
new file mode 100644
index 0000000..7038773
--- /dev/null
+++ b/modules/nixos/firefox/default.nix
@@ -0,0 +1,279 @@
+{
+  config,
+  inputs,
+  lib,
+  pkgs,
+  ...
+}:
+with lib; let
+  cfg = config.nixfiles.modules.firefox;
+in {
+  options.nixfiles.modules.firefox.enable = mkEnableOption "Firefox";
+
+  config = mkIf cfg.enable {
+    hm = {
+      imports = [inputs.arkenfox-nixos.hmModules.arkenfox];
+
+      home.packages = with pkgs; [profile-cleaner];
+
+      programs.firefox = {
+        enable = true;
+
+        package = pkgs.firefox;
+
+        arkenfox.enable = true;
+
+        profiles.default = let
+          mkCssWithRoot = css:
+            mkMerge [
+              (with config.colourScheme; ''
+                :root {
+                    --black: ${black};
+                    --red: ${red};
+                    --green: ${green};
+                    --yellow: ${yellow};
+                    --blue: ${blue};
+                    --magenta: ${magenta};
+                    --cyan: ${cyan};
+                    --white: ${white};
+                    --bright-black: ${brightBlack};
+                    --bright-red: ${brightRed};
+                    --bright-green: ${brightGreen};
+                    --bright-yellow: ${brightYellow};
+                    --bright-blue: ${brightBlue};
+                    --bright-magenta: ${brightMagenta};
+                    --bright-cyan: ${brightCyan};
+                    --bright-white: ${brightWhite};
+                    --background: ${background};
+                    --foreground: ${foreground};
+              '')
+              (with config.fontScheme; ''
+                    --sans-serif-font-family: "${sansSerifFont.family}", "${sansSerifFontFallback.family}", sans-serif;
+                    --sans-serif-font-size: ${toString sansSerifFont.size}px;
+                    --serif-font-family: "${serifFont.family}", "${serifFontFallback.family}", serif;
+                    --serif-font-size: ${toString serifFont.size}px;
+                    --monospace-font-family: "${monospaceFont.family}", "${monospaceFontFallback.family}", monospace;
+                    --monospace-font-size: ${toString monospaceFont.size}px;
+                }
+              '')
+              (builtins.readFile css)
+            ];
+        in {
+          id = 0;
+
+          isDefault = true;
+
+          userChrome = mkCssWithRoot ./userChrome.css;
+
+          userContent = mkCssWithRoot ./userContent.css;
+
+          extensions = with pkgs.nur.repos.rycee.firefox-addons; [
+            bitwarden
+            consent-o-matic
+            darkreader
+            localcdn
+            noscript
+            privacy-redirect
+            ublock-origin
+            violentmonkey
+          ];
+
+          # https://github.com/arkenfox/user.js/blob/master/user.js
+          arkenfox = {
+            enable = true;
+            "0000".enable = true;
+            "0100" = {
+              enable = true;
+              "0102" = {
+                enable = true;
+                "browser.startup.page" = {
+                  enable = true;
+                  value = 3;
+                };
+              };
+            };
+            "0200".enable = true;
+            "0300".enable = true;
+            "0400" = {
+              enable = false;
+              "0401" = {
+                enable = true;
+                "browser.safebrowsing.malware.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+                "browser.safebrowsing.phishing.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+              "0402" = {
+                enable = true;
+                "browser.safebrowsing.downloads.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+              "0404" = {
+                enable = true;
+                "browser.safebrowsing.downloads.remote.block_potentially_unwanted" = {
+                  enable = true;
+                  value = false;
+                };
+                "browser.safebrowsing.downloads.remote.block_uncommon" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+            };
+            "0600".enable = true;
+            "0700" = {
+              enable = true;
+              "0701" = {
+                enable = true;
+                "network.dns.disableIPv6" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+              "0710" = {
+                enable = true;
+                "network.trr.mode" = {
+                  enable = true;
+                  value = 5;
+                };
+              };
+            };
+            "0800" = {
+              enable = true;
+              "0801" = {
+                enable = true;
+                "keyword.enabled" = {
+                  enable = true;
+                  value = true;
+                };
+              };
+              "0808" = {
+                enable = true;
+                "browser.urlbar.suggest.engines" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+              "0810" = {
+                enable = true;
+                "browser.formfill.enable" = {
+                  enable = true;
+                  value = true;
+                };
+              };
+            };
+            "0900".enable = true;
+            "1000" = {
+              enable = true;
+              "1001"."browser.cache.disk.enable" = {
+                enable = true;
+                value = true;
+              };
+            };
+            "1200" = {
+              enable = true;
+            };
+            "1700" = {
+              enable = false;
+              "1701" = {
+                enable = true;
+                "privacy.userContext.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+                "privacy.userContext.ui.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+              "1702" = {
+                enable = true;
+                "privacy.userContext.newTabContainerOnLeftClick.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+            };
+            "2000" = {
+              enable = true;
+              "2022" = {
+                enable = true;
+                "media.eme.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+                "browser.eme.ui.enabled" = {
+                  enable = true;
+                  value = false;
+                };
+              };
+            };
+            "2400".enable = false;
+            "2600" = {
+              enable = true;
+              "2615" = {
+                enable = true;
+                "permissions.default.shortcuts" = {
+                  enable = true;
+                  value = 2;
+                };
+              };
+            };
+            "2700".enable = true;
+            "2800".enable = true;
+          };
+
+          settings = {
+            "app.update.auto" = false;
+            "browser.backspace_action" = 0;
+            "browser.bookmarks.max_backups" = 1;
+            "browser.disableResetPrompt" = true;
+            "browser.download.autohideButton" = false;
+            "browser.newtabpage.activity-stream.feeds.system.topsites" = false;
+            "browser.newtabpage.activity-stream.feeds.topsites" = false;
+            "browser.newtabpage.introShown" = true;
+            "browser.onboarding.enabled" = false;
+            "browser.search.update" = false;
+            "browser.startup.homepage_welcome_url" = "";
+            "browser.startup.homepage_welcome_url.additional" = "";
+            "browser.tabs.closeWindowWithLastTab" = true;
+            "browser.tabs.firefox-view" = false;
+            "browser.tabs.inTitlebar" =
+              if config.nixfiles.modules.kde.enable
+              then 1
+              else 0;
+            "browser.tabs.warnOnClose" = false;
+            "browser.tabs.warnOnCloseOtherTabs" = false;
+            "browser.tabs.warnOnOpen" = false;
+            "browser.toolbars.bookmarks.visibility" = "never";
+            "browser.urlbar.decodeURLsOnCopy" = true;
+            "browser.warnOnQuitShortcut" = false;
+            "extensions.pocket.enabled" = false;
+            "extensions.screenshots.disabled" = true;
+            "extensions.update.autoUpdateDefault" = false;
+            "extensions.update.enabled" = false;
+            "full-screen-api.warning.delay" = 0;
+            "full-screen-api.warning.timeout" = 0;
+            "general.autoScroll" = true;
+            "general.smoothScroll" = true;
+            "gfx.font_rendering.opentype_svg.enabled" = false;
+            "identity.fxaccounts.enabled" = false;
+            "media.autoplay.blocking_policy" = 2;
+            "media.autoplay.default" = 5;
+            "media.autoplay.enabled" = false;
+            "media.hardwaremediakeys.enabled" = false;
+            "reader.parse-on-load.enabled" = false;
+            "signon.rememberSignons" = false;
+            "toolkit.legacyUserProfileCustomizations.stylesheets" = true;
+          };
+        };
+      };
+    };
+  };
+}

Consider giving Nix/NixOS a try! <3