about summary refs log tree commit diff
path: root/modules/nixos/firefox
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2023-02-19 17:50:35 +0300
committerAzat Bahawi <azat@bahawi.net>2023-02-19 17:50:35 +0300
commit91fb4f28ef5d87e8bcf7749928d30ba4a9cbbd34 (patch)
treee07291fcb1cf62a561ffe58d1fd8e2968ff6fcb3 /modules/nixos/firefox
parent2023-02-15 (diff)
2023-02-19
Diffstat (limited to 'modules/nixos/firefox')
-rw-r--r--modules/nixos/firefox/default.nix279
-rw-r--r--modules/nixos/firefox/userChrome.css210
-rw-r--r--modules/nixos/firefox/userContent.css323
3 files changed, 812 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;
+          };
+        };
+      };
+    };
+  };
+}
diff --git a/modules/nixos/firefox/userChrome.css b/modules/nixos/firefox/userChrome.css
new file mode 100644
index 0000000..58e450e
--- /dev/null
+++ b/modules/nixos/firefox/userChrome.css
@@ -0,0 +1,210 @@
+@-moz-document url(chrome://browser/content/browser.xul), url(chrome://browser/content/browser.xhtml)
+{
+    /* :root { */
+    /*     /\* */
+    /*      * Helper colours. */
+    /*      *\/ */
+    /*     --background: var(--black) !important; */
+    /*     --foreground: var(--white) !important; */
+    /*     --background-alt: var(--bright-black) !important; */
+    /*     --foreground-alt: var(--bright-white) !important; */
+
+    /*     /\* */
+    /*      * Various root values that can be redefined. */
+    /*      *\/ */
+    /*     --arrowpanel-border-radius: 0 !important; */
+    /*     --autocomplete-popup-highlight-background: var(--background) !important; */
+    /*     --autocomplete-popup-highlight-color: var(--foreground) !important; */
+    /*     --backbutton-background: transparent !important; */
+    /*     --backbutton-border-color: transparent !important; */
+    /*     --tab-block-margin: 0 !important; */
+    /*     --tab-border-radius: 0 !important; */
+    /*     --tabs-border-color: transparent !important; */
+    /*     --tabs-top-border-width: 0 !important; */
+    /*     --toolbar-field-focus-border-color: var(--background) !important; */
+    /*     --toolbar-non-lwt-bgcolor: var(--background) !important; */
+    /*     --toolbar-non-lwt-bgimage: none !important; */
+    /*     --toolbar-non-lwt-textcolor: var(--foreground) !important; */
+    /*     --toolbarbutton-border-radius: 0 !important; */
+    /* } */
+
+    /*
+     ***
+     * Tabbar
+     ***
+     */
+
+    /*
+     * Apply colours and fonts.
+     */
+    /* .tabbrowser-tab { */
+    /*     color: var(--background-alt) !important; */
+    /*     font-family: var(--sans-serif-font-family) !important; */
+    /*     font-size: var(--sans-serif-font-size) !important; */
+    /* } */
+    /* .tabbrowser-tab[visuallyselected="true"] { */
+    /*     background: var(--background) !important; */
+    /*     color: var(--foreground) !important; */
+    /* } */
+
+    /*
+     * Not sure why is this shit even exists...
+     */
+    .titlebar-spacer {
+        display: none !important;
+    }
+
+    /*
+     * Disable borders and margins.
+     */
+    #tabbrowser-tabs {
+        border-inline-start: 0 !important;
+        /* padding-inline-start: 0 !important; */
+        margin-inline-start: 0 !important;
+    }
+    #tabbrowser-tabs[haspinnedtabs]:not([positionpinnedtabs])
+        > #tabbrowser-arrowscrollbox
+        > .tabbrowser-tab[first-visible-unpinned-tab] {
+        margin-inline-start: none !important;
+    }
+    .tabbrowser-tab::after,
+    .tabbrowser-tab::before {
+        border: none !important;
+    }
+
+    /*
+     * Make tabs backgroundless.
+     */
+    /* .tab-background, */
+    /* .tab-line { */
+    /*     display: none !important; */
+    /* } */
+
+    /*
+     * Stretch tabs to the max by default.
+     */
+    .tabbrowser-tab[fadein]:not([pinned="true"]) {
+        max-width: 100% !important;
+    }
+
+    /*
+     * Fix favicon location.
+     */
+    /* .tab-icon-image { */
+    /*     margin-inline-end: 10px !important; */
+    /*     margin-top: 0px !important; */
+    /* } */
+
+    /*
+     * "C-t" exists.
+     */
+    /* #tabs-newtab-button, */
+    /* #TabsToolbar #new-tab-button { */
+    /*     display: none !important; */
+    /* } */
+
+    /*
+     * "C-w" exists.
+     */
+    .tab-close-button {
+        display: none !important;
+    }
+
+    /*
+     ***
+     * Navbar & urlbar.
+     ***
+     */
+
+    /*
+     * Remove useless buttons.
+     */
+    /* #forward-button, */
+    /* #back-button, */
+    /* #reload-button, */
+    /* #stop-button { */
+    /*     display: none !important; */
+    /* } */
+
+    /*
+     * Remove padding between urlbar and side elements.
+     */
+    #customizableui-special-spring1,
+    #customizableui-special-spring2 {
+        display: none !important;
+    }
+
+    /* #urlbar { */
+    /*     background: var(--background) !important; */
+    /*     color: var(--forground) !important; */
+    /*     font-family: var(--sans-serif-font-family) !important; */
+    /*     font-size: var(--sans-serif-font-size) !important; */
+    /*     border-color: transparent !important; */
+    /* } */
+
+    /* #urlbar:not(:-moz-lwtheme):not([focused="true"]) > #urlbar-background, */
+    /* #searchbar:not(:-moz-lwtheme):not(:focus-within) { */
+    /*     border: none !important; */
+    /* } */
+
+    /* #urlbar *|*.textbox-input::-moz-placeholder { */
+    /*     color: transparent !important; */
+    /* } */
+
+    /* .urlbar-icon:hover:not([disabled]), */
+    /* .urlbar-icon-wrapper:hover:not([disabled]) { */
+    /*     background-color: var(--background-alt) !important; */
+    /* } */
+
+    /* #urlbar-background { */
+    /*     background: transparent !important; */
+    /* } */
+
+    /* .urlbarView-tags, */
+    /* .urlbarView-url, */
+    /* .urlbarView-title:not(:empty) ~ .urlbarView-action { */
+    /*     font-size: var(--sans-serif-font-size) !important; */
+    /* } */
+
+    .urlbarView-row[label="Firefox Suggest"] {
+        margin-block-start: 0 !important;
+    }
+    .urlbarView-row[label="Firefox Suggest"]::before {
+        display: none !important;
+    }
+
+    /*
+     ***
+     * Misc.
+     ***
+     */
+
+    /*
+     * Call indicator that some "designer" decided to make floating and
+     * impossible to hide.
+     */
+    #webrtcIndicator {
+        display: none !important;
+    }
+
+    /*
+     * Disable some context menu entries.
+     */
+    #context-navigation {
+        display: none !important;
+    }
+
+    /*
+     * Disable all animations.
+     */
+    /* * { */
+    /*     transition: none !important; */
+    /* } */
+
+    /*
+     * Remove dumb websites that Mozilla is forced to include.
+     */
+    .search-one-offs {
+        display: none !important;
+    }
+}
diff --git a/modules/nixos/firefox/userContent.css b/modules/nixos/firefox/userContent.css
new file mode 100644
index 0000000..2de8cde
--- /dev/null
+++ b/modules/nixos/firefox/userContent.css
@@ -0,0 +1,323 @@
+@-moz-document media-document(all) {
+    body {
+        background-image: none !important;
+        background-color: var(--background) !important;
+    }
+}
+
+@-moz-document regexp("about:(blank|home|newtab|privatebrowsing|welcome)") {
+    html,
+    body {
+        background: var(--background) !important;
+    }
+
+    body {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://(www)?yandex\.(com|ru)/search/.*")
+{
+    #search-result-aside,
+    .RelatedAbove {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://music\.yandex\.ru.*")
+{
+    .bar-below.bar-below_plus,
+    .footer,
+    .notify,
+    .teaser {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://(.*.)?gitlab(\..*)?\.(com|org).*")
+{
+    body {
+        font-family: var(--sans-serif-font-family) !important;
+        font-size: var(--sans-serif-font-size) !important;
+    }
+
+    code {
+        font-family: var(--monospace-font-family) !important;
+        font-size: var(--monospace-font-size) !important;
+    }
+}
+
+@-moz-document regexp("https?://(.*\.)?github.com.*")
+{
+    #org-repo-pin-select-menu,
+    #sponsor-button,
+    .dropdown-divider,
+    .footer,
+    .octicon.octicon-info,
+    .pt-3.mt-3.d-none.d-md-block, /* Profile achievements. */
+    .starring-container,
+    .user-following-container,
+    .user-profile-link,
+    .user-status-circle-badge-container,
+    .user-status-container,
+    a[href^="/account/choose?action=upgrade"],
+    a[href^="/codespaces"],
+    a[href^="/collections"],
+    a[href^="/events"],
+    a[href^="/explore"],
+    a[href^="/marketplace"],
+    a[href^="/organizations/enterprise"],
+    a[href^="/sponsors"],
+    a[href^="/topics"],
+    a[href^="/trending"] {
+        display: none !important;
+    }
+
+    .application-main {
+        padding-bottom: 20px !important;
+    }
+
+    .blob-num,
+    .blob-code-inner {
+        font-family: var(--monospace-font-family) !important;
+        font-size: var(--monospace-font-size) !important;
+    }
+}
+
+@-moz-document regexp("https?://github.com/?")
+{
+    .application-main {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://.*(stack(exchange|overflow)|askubuntu|superuser|serverfault)\.com/questions/.*")
+{
+    html,
+    body {
+        --ff-mono: var(--monospace-font-family) !important;
+        --ff-sans: var(--sans-serif-font-family) !important;
+        --ff-serif: var(--serif-font-family) !important;
+    }
+
+    #announcement-banner,
+    #footer,
+    #left-sidebar,
+    #noscript-warning,
+    #notify-container,
+    #post-form,
+    #sidebar,
+    .ai-start,
+    .bottom-notice,
+    .comment-user,
+    .d-flex.g4,
+    .d-flex.s-btn-group,
+    .js-add-link.comments-link,
+    .js-consent-banner,
+    .js-dismissable-hero,
+    .js-post-issue,
+    .js-show-link.comments-link,
+    .post-taglist,
+    .s-notice,
+    .s-topbar,
+    .site-header,
+    a.ws-nowrap {
+        display: none !important;
+    }
+
+    #mainbar {
+        width: 100% !important;
+    }
+
+    #content {
+        margin-top: -50px !important;
+        border-width: 0 0 0 0 !important;
+    }
+}
+
+@-moz-document regexp("https?://kubernetes\.io/docs/.*")
+{
+    .announcement,
+    .announcement-main,
+    .d-none {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://min\.io/docs/.*")
+{
+    #cookie {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://werf\.io/documentation/.*")
+{
+    .guides-banner {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://habr\.com/(ru|en)/(article|company/.*/news|blog|post)/.*")
+{
+    .Vue-Toastification__container,
+    .tm-article-presenter__footer,
+    .tm-article-presenter__meta,
+    .tm-article-snippet__labels,
+    .tm-article-sticky-panel,
+    .tm-base-layout__header,
+    .tm-block.tm-block_spacing-bottom,
+    .tm-block_spacing-around,
+    .tm-comment-footer,
+    .tm-comment__header,
+    .tm-editoral-subscription,
+    .tm-footer,
+    .tm-footer-menu,
+    .tm-header,
+    .tm-notice,
+    .tm-page__header,
+    .tm-page__sidebar,
+    .tm-placeholder-inset,
+    .tm-placeholder-promo,
+    .tm-user-info,
+    vue-portal-target {
+        display: none !important;
+    }
+
+    * {
+        transition: none !important;
+    }
+
+    html,
+    body {
+        font-family: var(--sans-serif-font-family) !important;
+        font-size: var(--sans-serif-font-size) !important;
+    }
+
+    #app {
+        height: auto !important;
+    }
+
+    .tm-article-presenter__footer,
+    .tm-page__main_has-sidebar {
+        margin-left: auto !important;
+        margin-right: auto !important;
+        max-width: 100% !important;
+    }
+
+    .tm-page {
+        padding: 0 !important;
+    }
+
+    .tm-comment__buttons {
+        margin: 0 !important;
+    }
+
+    html,
+    body {
+        font-family: var(--sans-serif-font-family) !important;
+        font-size: var(--sans-serif-font-size) !important;
+    }
+
+    code {
+        font-family: var(--monospace-font-family) !important;
+        font-size: var(--monospace-font-size) !important;
+    }
+}
+
+@-moz-document regexp("https?://jisho\.org.*")
+{
+    header,
+    footer {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?:\/\/gog\.com.*") {
+    .galaxy-section-wrapper,
+    footer {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://steamdb\.info.*")
+{
+    #steamdb-extension-protip {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://(.*\.)?hh\.ru.*")
+{
+    .HH-Supernova-Footer,
+    .index-dashboard-applicant__banners,
+    .notification-manager,
+    .resume-sidebar-background,
+    .supernova-overlay {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://www\.songsterr\.com.*")
+{
+    #favorite,
+    #fullscreen,
+    #logo,
+    #menu-favorites,
+    #menu-help,
+    #menu-plus,
+    #menu-signin,
+    #menu-submit,
+    #promo,
+    #revisions,
+    #showroom,
+    #showroom_sidebar,
+    #text-showroom,
+    footer {
+        display: none !important;
+    }
+}
+
+@-moz-document regexp("https?://developer\.mozilla\.org.*")
+{
+    #nav-footer,
+    .main-document-header-container.top-navigation,
+    .mdn-cta-container {
+        display: none !important;
+    }
+
+    .sidebar {
+        --offset: default !important;
+    }
+
+    html,
+    body {
+        font-family: var(--sans-serif-font-family) !important;
+        font-size: var(--sans-serif-font-size) !important;
+    }
+}
+
+@-moz-document regexp("https?://(.*\.)?wikipedia\.org/wiki/.*")
+{
+    #footer,
+    #mp-topbanner,
+    #siteNotice,
+    #siteSub,
+    .mw-footer-container,
+    .mw-header,
+    .vector-page-toolbar {
+        display: none !important;
+    }
+
+    html,
+    body {
+        font-family: var(--sans-serif-font-family) !important;
+        font-size: var(--sans-serif-font-size) !important;
+    }
+
+    .k-player,
+    body.mediawiki,
+    #dialogEngineContainer #dialogEngineDialog {
+        background: inherit !important;
+    }
+}

Consider giving Nix/NixOS a try! <3