From 710de6ac83fe6716677b10c02f74561551828a5b Mon Sep 17 00:00:00 2001 From: chayleaf Date: Tue, 6 Feb 2024 14:59:06 +0700 Subject: [PATCH] home/firefox: make more settings declarative --- flake.lock | 11 +-- flake.nix | 6 +- home/modules/firefox.nix | 116 ++++++++++++++++++++++++++---- pkgs/firefox-addons/addons.json | 1 - pkgs/firefox-addons/generated.nix | 16 +---- 5 files changed, 112 insertions(+), 38 deletions(-) diff --git a/flake.lock b/flake.lock index 7a72ce2..40f8eec 100644 --- a/flake.lock +++ b/flake.lock @@ -150,15 +150,16 @@ ] }, "locked": { - "lastModified": 1706473109, - "narHash": "sha256-iyuAvpKTsq2u23Cr07RcV5XlfKExrG8gRpF75hf1uVc=", - "owner": "nix-community", + "lastModified": 1707204789, + "narHash": "sha256-S3QVfyUPa7zzeyk0TAqr9i9FLwnaO/6zPx4DVCNEeqA=", + "owner": "chayleaf", "repo": "home-manager", - "rev": "d634c3abafa454551f2083b054cd95c3f287be61", + "rev": "8abb90abf382972e8cd2f3c3b3cdc93c1502b067", "type": "github" }, "original": { - "owner": "nix-community", + "owner": "chayleaf", + "ref": "librewolf", "repo": "home-manager", "type": "github" } diff --git a/flake.nix b/flake.nix index a0072d7..262f331 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; home-manager = { - url = "github:nix-community/home-manager"; + url = "github:chayleaf/home-manager/librewolf"; inputs.nixpkgs.follows = "nixpkgs"; }; nix-gaming = { @@ -65,6 +65,7 @@ # it takes the paths for modules from filesystem as opposed to flake inputs dev = { # coop-ofd = true; + # home-manager = true; # mobile-nixos = true; # nixos-router = true; # notnft = true; @@ -82,7 +83,8 @@ (name: input: if dev.${name} or false then (if input._type or null == "flake" - then (import base-inputs.flake-compat { src = /${devPath}/${name}; }).defaultNix + then let inputs = input.inputs // { self = (import /${devPath}/${name}/flake.nix).outputs inputs; }; + in inputs.self else /${devPath}/${name}) else input) base-inputs; diff --git a/home/modules/firefox.nix b/home/modules/firefox.nix index f2896d8..55c6b5e 100644 --- a/home/modules/firefox.nix +++ b/home/modules/firefox.nix @@ -5,10 +5,8 @@ }: { - imports = [ - ./gui.nix - ]; - home.file.".mozilla/firefox/profiles.ini".target = ".librewolf/profiles.ini"; + imports = [ ./gui.nix ]; + programs.firefox = { enable = true; package = pkgs.wrapFirefox pkgs.librewolf-unwrapped { @@ -40,20 +38,96 @@ youtube-shorts-block ]) ++ (with pkgs.firefoxAddons; [ fastforwardteam - middle-mouse-button-scroll rikaitan youtube-nonstop ]); - settings = lib.mkIf config.phone.enable { - "dom.w3c.touch_events.enabled" = true; - "apz.allow_zooming" = true; - "apz.allow_double_tap_zooming" = true; - "dom.w3c_touch_events.legacy_apis.enabled" = true; - "browser.tabs.inTitlebar" = 1; - "toolkit.legacyUserProfileCustomizations.stylesheets" = true; - "browser.urlbar.clickSelectsAll" = true; - "toolkit.cosmeticAnimations.enabled" = false; - "browser.download.animateNotifications" = false; + search.default = "search.pavluk.org"; + search.privateDefault = "search.pavluk.org"; + search.force = true; + search.engines."search.pavluk.org" = { + name = "search.pavluk.org"; + description = "SearXNG is a metasearch engine that respects your privacy."; + queryCharset = "UTF-8"; + searchForm = "https://search.pavluk.org/search"; + iconURL = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5Mm1tIiBoZWlnaHQ9IjkybW0iIHZpZXdCb3g9IjAgMCA5MiA5MiI+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTQwLjkyMSAtMTcuNDE3KSI+PGNpcmNsZSBjeD0iNzUuOTIxIiBjeT0iNTMuOTAzIiByPSIzMCIgc3R5bGU9ImZpbGw6bm9uZTtmaWxsLW9wYWNpdHk6MTtzdHJva2U6IzMwNTBmZjtzdHJva2Utd2lkdGg6MTA7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MSIvPjxwYXRoIGQ9Ik02Ny41MTUgMzcuOTE1YTE4IDE4IDAgMCAxIDIxLjA1MSAzLjMxMyAxOCAxOCAwIDAgMSAzLjEzOCAyMS4wNzgiIHN0eWxlPSJmaWxsOm5vbmU7ZmlsbC1vcGFjaXR5OjE7c3Ryb2tlOiMzMDUwZmY7c3Ryb2tlLXdpZHRoOjU7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MSIvPjxyZWN0IHdpZHRoPSIxOC44NDYiIGhlaWdodD0iMzkuOTYzIiB4PSIzLjcwNiIgeT0iMTIyLjA5IiByeT0iMCIgc3R5bGU9Im9wYWNpdHk6MTtmaWxsOiMzMDUwZmY7ZmlsbC1vcGFjaXR5OjE7c3Ryb2tlOm5vbmU7c3Ryb2tlLXdpZHRoOjg7c3Ryb2tlLW1pdGVybGltaXQ6NDtzdHJva2UtZGFzaGFycmF5Om5vbmU7c3Ryb2tlLW9wYWNpdHk6MSIgdHJhbnNmb3JtPSJyb3RhdGUoLTQ2LjIzNSkiLz48L2c+PC9zdmc+"; + urls = [ + { "params" = [ { "name" = "q"; "value" = "{searchTerms}"; } ]; + "rels" = [ "results" ]; + "template" = "https://search.pavluk.org/search"; + "method" = "POST"; } + { "params" = [ ]; + "rels" = [ "suggestions" ]; + "template" = "https://search.pavluk.org/autocompleter?q={searchTerms}"; + "type" = "application/x-suggestions+json"; + "method" = "POST"; } + ]; + }; + settings = let + langs = [ "ar" "el" "he" "ja" "ko" "th" "x-armn" "x-beng" "x-cans" "x-cyrillic" "x-devanagari" + "x-ethi" "x-geor" "x-gujr" "x-guru" "x-khmr" "x-knda" "x-math" "x-mlym" "x-orya" + "x-sinh" "x-tamil" "x-telu" "x-tibt" "x-unicode" "x-western" "zh-CN" "zh-HK" "zh-TW" ]; + genFonts = prefix: func: + lib.genAttrs + (map (lang: "font.name.${prefix}.${lang}") langs) + (s: func (lib.removePrefix "font.name.${prefix}." s)); + notoFamilies = { + ar = "Arabic"; x-armn = "Armenian"; x-beng = "Bengali"; x-cans = "Canadian Aboriginal"; + ja = "CJK JP"; ko = "CJK KR"; zh-CN = "CJK SC"; zh-HK = "CJK HK"; zh-TW = "CJK TC"; + /* cyrillic = "Cyrillic"; */ x-devanagari = "Devanagari"; /* el = "Greek"; */ + x-ethi = "Ethiopic"; x-geor = "Georgian"; x-gujr = "Gujarati"; x-guru = "Gurmukhi"; + he = "Hebrew"; x-khmr = "Khmer"; x-knda = "Kannada"; x-math = "Math"; x-mlym = "Malayalam"; + x-orya = "Oriya"; x-sinh = "Sinhala"; x-tamil = "Tamil"; x-telu = "Telugu"; th = "Thai"; + x-tibt = "Tibetan"; /* x-unicode = "Other Writing Systems"; x-western = "Latin"; */ + }; + in genFonts "monospace" (_: "Noto Sans Mono") + // genFonts "sans-serif" (lang: if notoFamilies?${lang} then "Noto Sans ${notoFamilies.${lang}}" else "Noto Sans") + // genFonts "serif" (lang: if notoFamilies?${lang} then "Noto Serif ${notoFamilies.${lang}}" else "Noto Serif") + // { + "font.name.monospace.ja" = "Noto Sans Mono CJK JP"; + "font.name.monospace.ko" = "Noto Sans Mono CJK KR"; + "font.name.monospace.zh-CN" = "Noto Sans Mono CJK SC"; + "font.name.monospace.zh-HK" = "Noto Sans Mono CJK HK"; + "font.name.monospace.zh-TW" = "Noto Sans Mono CJK TC"; + "font.name.serif.ar" = "Noto Sans Arabic"; + "font.name.serif.x-cans" = "Noto Sans Canadian Aboriginal"; + "font.name.serif.x-math" = "Noto Sans Math"; + "font.name.serif.x-orya" = "Noto Sans Oriya"; + + # user-facing tweaks + "browser.quitShortcut.disabled" = true; + "browser.search.suggest.enabled" = true; + "general.autoScroll" = true; + "middlemouse.paste" = false; + "spellchecker.dictionary_path" = pkgs.symlinkJoin { + name = "firefox-hunspell-dicts"; + paths = with pkgs.hunspellDicts; [ en-us-large ru-ru ]; + }; + "widget.content.allow-gtk-dark-theme" = true; + + # user agent and overall behavioral tweaks + "gfx.webrender.all" = true; + "general.useragent.compatMode.firefox" = true; + "image.jxl.enabled" = true; + "noscript.sync.enabled" = true; + "privacy.donottrackheader.enabled" = true; + "webgl.disabled" = false; + "xpinstall.signatures.required" = false; + + # privacy tweaks + "browser.contentblocking.category" = "strict"; + "intl.accept_languages" = "en-US, en"; + "javascript.use_us_english_locale" = true; + "privacy.clearOnShutdown.cache" = false; + "privacy.clearOnShutdown.cookies" = false; + "privacy.clearOnShutdown.downloads" = false; + "privacy.clearOnShutdown.formdata" = false; + "privacy.clearOnShutdown.history" = false; + "privacy.clearOnShutdown.offlineApps" = false; + "privacy.clearOnShutdown.sessions" = false; + "privacy.fingerprintingProtection" = true; + "privacy.trackingprotection.enabled" = true; + "privacy.trackingprotection.emailtracking.enabled" = true; + "privacy.trackingprotection.socialtracking.enabled" = true; }; } (let @@ -69,6 +143,18 @@ userContent = concatFiles "${pkgs.mobile-config-firefox}/etc/mobile-config-firefox/common" + concatFiles "${pkgs.mobile-config-firefox}/etc/mobile-config-firefox/userContent"; + + settings = { + "dom.w3c.touch_events.enabled" = true; + "apz.allow_zooming" = true; + "apz.allow_double_tap_zooming" = true; + "dom.w3c_touch_events.legacy_apis.enabled" = true; + "browser.tabs.inTitlebar" = 1; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "browser.urlbar.clickSelectsAll" = true; + "toolkit.cosmeticAnimations.enabled" = false; + "browser.download.animateNotifications" = false; + }; }) ]; }; diff --git a/pkgs/firefox-addons/addons.json b/pkgs/firefox-addons/addons.json index 3001243..5a5d1b6 100644 --- a/pkgs/firefox-addons/addons.json +++ b/pkgs/firefox-addons/addons.json @@ -1,6 +1,5 @@ [ { "slug": "fastforwardteam" }, - { "slug": "middle-mouse-button-scroll" }, { "slug": "rikaitan" }, { "slug": "youtube-nonstop" } ] diff --git a/pkgs/firefox-addons/generated.nix b/pkgs/firefox-addons/generated.nix index f3dc626..22a83b4 100644 --- a/pkgs/firefox-addons/generated.nix +++ b/pkgs/firefox-addons/generated.nix @@ -21,20 +21,6 @@ platforms = platforms.all; }; }; - "middle-mouse-button-scroll" = buildFirefoxXpiAddon { - pname = "middle-mouse-button-scroll"; - version = "0.3.2"; - addonId = "{b687f6ef-3299-4a75-8279-8b1c30dfcc9d}"; - url = "https://addons.mozilla.org/firefox/downloads/file/3505309/middle_mouse_button_scroll-0.3.2.xpi"; - sha256 = "d21d29b29a7bd3fae5407d995737c4c41d66daf73729b88ad39d149223362412"; - meta = with lib; - { - homepage = "https://github.com/StoyanDimitrov/middle-mouse-button-scroll"; - description = "Scroll fast or precise through long documents with pressed middle mouse button"; - mozPermissions = [ "*://*/*" ]; - platforms = platforms.all; - }; - }; "rikaitan" = buildFirefoxXpiAddon { pname = "rikaitan"; version = "24.1.22.0"; @@ -77,4 +63,4 @@ platforms = platforms.all; }; }; - } \ No newline at end of file + }