From 558cde37c66b29807c8cb536f0a2236a8acad49e Mon Sep 17 00:00:00 2001 From: Soispha Date: Fri, 28 Apr 2023 16:12:08 +0200 Subject: Refactor(hm/conf/firefox): For a cleaner default.nix --- home-manager/config/firefox/chrome/userChrome.css | 41 ---- .../config/firefox/config/bookmarks/default.nix | 16 ++ .../config/firefox/config/chrome/userChrome.css | 41 ++++ .../firefox/config/extensions/extensions.json | 51 +++++ .../config/firefox/config/prefs/default.nix | 73 ++++++ .../config/firefox/config/prefs/override.js | 137 ++++++++++++ .../firefox/config/search/engines/default.nix | 59 +++++ home-manager/config/firefox/default.nix | 244 +-------------------- .../config/firefox/functions/bookmarks/default.nix | 49 +++++ .../firefox/functions/extensions/default.nix | 26 +++ .../firefox/functions/extensions/video-pauser.nix | 31 +++ .../config/firefox/scripts/update_extensions | 2 +- .../config/firefox/settings/extensions.json | 51 ----- home-manager/config/firefox/settings/override.js | 137 ------------ 14 files changed, 491 insertions(+), 467 deletions(-) delete mode 100644 home-manager/config/firefox/chrome/userChrome.css create mode 100644 home-manager/config/firefox/config/bookmarks/default.nix create mode 100644 home-manager/config/firefox/config/chrome/userChrome.css create mode 100644 home-manager/config/firefox/config/extensions/extensions.json create mode 100644 home-manager/config/firefox/config/prefs/default.nix create mode 100644 home-manager/config/firefox/config/prefs/override.js create mode 100644 home-manager/config/firefox/config/search/engines/default.nix create mode 100644 home-manager/config/firefox/functions/bookmarks/default.nix create mode 100644 home-manager/config/firefox/functions/extensions/default.nix create mode 100644 home-manager/config/firefox/functions/extensions/video-pauser.nix delete mode 100644 home-manager/config/firefox/settings/extensions.json delete mode 100644 home-manager/config/firefox/settings/override.js (limited to 'home-manager/config') diff --git a/home-manager/config/firefox/chrome/userChrome.css b/home-manager/config/firefox/chrome/userChrome.css deleted file mode 100644 index 0b3aff77..00000000 --- a/home-manager/config/firefox/chrome/userChrome.css +++ /dev/null @@ -1,41 +0,0 @@ -/* thickness of tab when you have too many open tabs */ -.tabbrowser-tab:not([pinned="true"]) { - min-width: 10px !important; - min-height: 10px !important; -} - -/* tab height -#TabsToolbar .tabbrowser-tabs { -min-height: 10px !important; -} -*/ - -/* -.tabbrowser-tab {min-width: 016px !important;} -.tabbrowser-tab {clip-width: 016px !important;} -*/ - -/* the + button that opens new tabs */ -#TabsToolbar .tabs-newtab-button { - margin-left: 10px !important; - height: Auto !important; -} - -#main-window[privatebrowsingmode="temporary"] #navigator-toolbox { - background-color: #c40944 !important; -} - -/* close button inside a tab */ -.tab-close-button * { - width: 10px !important; - height: 10px !important; -} - -/* bookmark toolbar */ -#personal-bookmarks .bookmark-item > .toolbarbutton-text { - font-size: 10pt !important; -} -#personal-bookmarks .bookmark-item > .toolbarbutton-icon { - height: 12px !important; - width: 12px !important; -} diff --git a/home-manager/config/firefox/config/bookmarks/default.nix b/home-manager/config/firefox/config/bookmarks/default.nix new file mode 100644 index 00000000..51f5d432 --- /dev/null +++ b/home-manager/config/firefox/config/bookmarks/default.nix @@ -0,0 +1,16 @@ +[ + { + name = "Feed - Piped"; + url = "https://piped.video/feed"; + } + + { + name = "DeepL Translate"; + url = "https://www.deepl.com/translator#en/de/test"; + } + + { + name = "HM Options"; + url = "https://mipmip.github.io/home-manager-option-search/"; + } +] diff --git a/home-manager/config/firefox/config/chrome/userChrome.css b/home-manager/config/firefox/config/chrome/userChrome.css new file mode 100644 index 00000000..0b3aff77 --- /dev/null +++ b/home-manager/config/firefox/config/chrome/userChrome.css @@ -0,0 +1,41 @@ +/* thickness of tab when you have too many open tabs */ +.tabbrowser-tab:not([pinned="true"]) { + min-width: 10px !important; + min-height: 10px !important; +} + +/* tab height +#TabsToolbar .tabbrowser-tabs { +min-height: 10px !important; +} +*/ + +/* +.tabbrowser-tab {min-width: 016px !important;} +.tabbrowser-tab {clip-width: 016px !important;} +*/ + +/* the + button that opens new tabs */ +#TabsToolbar .tabs-newtab-button { + margin-left: 10px !important; + height: Auto !important; +} + +#main-window[privatebrowsingmode="temporary"] #navigator-toolbox { + background-color: #c40944 !important; +} + +/* close button inside a tab */ +.tab-close-button * { + width: 10px !important; + height: 10px !important; +} + +/* bookmark toolbar */ +#personal-bookmarks .bookmark-item > .toolbarbutton-text { + font-size: 10pt !important; +} +#personal-bookmarks .bookmark-item > .toolbarbutton-icon { + height: 12px !important; + width: 12px !important; +} diff --git a/home-manager/config/firefox/config/extensions/extensions.json b/home-manager/config/firefox/config/extensions/extensions.json new file mode 100644 index 00000000..1de32896 --- /dev/null +++ b/home-manager/config/firefox/config/extensions/extensions.json @@ -0,0 +1,51 @@ +{ + "darkreader": { + "addonId": "addon@darkreader.org", + "pname": "darkreader", + "sha256": "sha256:16ba6337fcff7ad85e08ad51b384ba26ff751b2b2ded12309f75e8337ace925a", + "url": "https://addons.mozilla.org/firefox/downloads/file/4095037/darkreader-4.9.63.xpi", + "version": "4.9.63" + }, + "keepassxc-browser": { + "addonId": "keepassxc-browser@keepassxc.org", + "pname": "keepassxc-browser", + "sha256": "sha256:ce2275eb1f0a4b0ce2342204d00d62033f81f6dcb9e021cff38f51273e614f20", + "url": "https://addons.mozilla.org/firefox/downloads/file/4094964/keepassxc_browser-1.8.6.1.xpi", + "version": "1.8.6.1" + }, + "libredirect": { + "addonId": "7esoorv3@alefvanoon.anonaddy.me", + "pname": "libredirect", + "sha256": "sha256:57d6adbaabf74f386be88d63906992be46cf77c485c1c00afa27161ef3bbb8d4", + "url": "https://addons.mozilla.org/firefox/downloads/file/4079849/libredirect-2.5.4.xpi", + "version": "2.5.4" + }, + "simple-tab-groups": { + "addonId": "simple-tab-groups@drive4ik", + "pname": "simple-tab-groups", + "sha256": "sha256:2e955a41bafc01315ad435160e5be25a3b91d06555fba8097acc8b396b4df69c", + "url": "https://addons.mozilla.org/firefox/downloads/file/4098262/simple_tab_groups-5.1.xpi", + "version": "5.1" + }, + "tridactyl-vim": { + "addonId": "tridactyl.vim@cmcaine.co.uk", + "pname": "tridactyl-vim", + "sha256": "sha256:08b7af97bef05300ab3ac3ad721322ff00505631233482568fc4489c16d51b71", + "url": "https://addons.mozilla.org/firefox/downloads/file/4036604/tridactyl_vim-1.23.0.xpi", + "version": "1.23.0" + }, + "ublock-origin": { + "addonId": "uBlock0@raymondhill.net", + "pname": "ublock-origin", + "sha256": "sha256:d7666b963c2969b0014937aae55472eea5098ff21ed3bea8a2e1f595f62856c1", + "url": "https://addons.mozilla.org/firefox/downloads/file/4092158/ublock_origin-1.48.4.xpi", + "version": "1.48.4" + }, + "video-pauser": { + "addonId": "video-pauser@addons.vhack.eu", + "pname": "video-pauser", + "sha256": "sha256:da02e29f1d50d3a6db8a28bb7972afaeaa788bb8d38a2e9ebbfcd73d65d84841", + "url": "https://addons.mozilla.org/firefox/downloads/file/4098103/video_pauser-0.1.0.xpi", + "version": "0.1.0" + } +} diff --git a/home-manager/config/firefox/config/prefs/default.nix b/home-manager/config/firefox/config/prefs/default.nix new file mode 100644 index 00000000..d8dab86d --- /dev/null +++ b/home-manager/config/firefox/config/prefs/default.nix @@ -0,0 +1,73 @@ +# vim: ts=2 +{ + pkgs, + config, + user_js, + lib, + ... +}: let + bookmarks = import ../bookmarks; + firefoxBookmarksFile = (import ../../functions/bookmarks) {inherit lib pkgs;}; + user_js_override = pkgs.writeText "user.override.js" (builtins.readFile ./override.js); +in + pkgs.runCommand "user.js" {} '' + mkdir $out; + cat "${user_js}/user.js" > $out/user.js; + cat "${user_js_override}" >> $out/user.js; + + cat << EOF >> $out/user.js; + // My bookmarks + user_pref("browser.bookmarks.file", "${toString (firefoxBookmarksFile bookmarks)}"); + user_pref("browser.places.importBookmarksHTML", true); + + // Allow my custom css + user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); + + // might improve performance TODO + user_pref("gfx.webrender.all", true); + + // disable updates (pretty pointless with nix) + user_pref("extensions.update.autoUpdateDefault", false); + user_pref("extensions.update.enabled", false); + user_pref("app.update.channel", "default"); + + user_pref("browser.ctrlTab.recentlyUsedOrder", false); + + user_pref("browser.download.useDownloadDir", true); + user_pref("browser.download.dir", "${config.home.homeDirectory}/media/downloads"); + user_pref("browser.download.folderList", 2); # TODO + user_pref("browser.download.viewableInternally.typeWasRegistered.svg", true); + user_pref("browser.download.viewableInternally.typeWasRegistered.webp", true); + user_pref("browser.download.viewableInternally.typeWasRegistered.xml", true); + + // TODO what does this do? + user_pref("browser.search.widget.inNavBar", true); + + user_pref("browser.shell.checkDefaultBrowser", false); + user_pref("browser.tabs.loadInBackground", true); + user_pref("browser.urlbar.placeholderName", "Brave"); + + // Set the tabs and bookmarks + user_pref("browser.tabs.inTitlebar", 1); + user_pref("browser.toolbars.bookmarks.visibility", "always"); + + // Theme + user_pref("extensions.activeThemeID", "firefox-alpenglow@mozilla.org"); + user_pref("extensions.extensions.activeThemeID", "firefox-alpenglow@mozilla.org"); + + // highlight all entries when searching + user_pref("findbar.highlightAll", true); + + // TODO + //user_pref("extensions.webcompat.enable_picture_in_picture_overrides", true); + //user_pref("extensions.webcompat.enable_shims", true); + //user_pref("extensions.webcompat.perform_injections", true); + //user_pref("extensions.webcompat.perform_ua_overrides", true); + + // onlykey / copied from a yubikey config + //user_pref("security.webauth.u2f", true); + //user_pref("security.webauth.webauthn", true); + //user_pref("security.webauth.webauthn_enable_softtoken", true); + //user_pref("security.webauth.webauthn_enable_usbtoken", true); + EOF + '' diff --git a/home-manager/config/firefox/config/prefs/override.js b/home-manager/config/firefox/config/prefs/override.js new file mode 100644 index 00000000..ca03e8ed --- /dev/null +++ b/home-manager/config/firefox/config/prefs/override.js @@ -0,0 +1,137 @@ +/* + 0100: STARTUP + 0200: GEOLOCATION / LANGUAGE / LOCALE + 0300: QUIETER FOX + 0400: SAFE BROWSING + 0600: BLOCK IMPLICIT OUTBOUND + 0700: DNS / DoH / PROXY / SOCKS / IPv6 + 0800: LOCATION BAR / SEARCH BAR / SUGGESTIONS / HISTORY / FORMS + 0900: PASSWORDS + 1000: DISK AVOIDANCE + 1200: HTTPS (SSL/TLS / OCSP / CERTS / HPKP) + 1400: FONTS + 1600: HEADERS / REFERERS + 1700: CONTAINERS + 2000: PLUGINS / MEDIA / WEBRTC + 2400: DOM (DOCUMENT OBJECT MODEL) + 2600: MISCELLANEOUS + 2700: ETP (ENHANCED TRACKING PROTECTION) + 2800: SHUTDOWN & SANITIZING + 4500: RFP (RESIST FINGERPRINTING) + 5000: OPTIONAL OPSEC + 5500: OPTIONAL HARDENING + 6000: DON'T TOUCH + 7000: DON'T BOTHER + 8000: DON'T BOTHER: FINGERPRINTING + 9000: NON-PROJECT RELATED + 9999: DEPRECATED / REMOVED / LEGACY / RENAMED +*/ + + +// restore session +user_pref("browser.startup.page", 3); // 0102 + +user_pref("browser.startup.homepage", "file:///home/dt/home.html"); // 0103 +user_pref("browser.newtabpage.enabled", true); // 0104 + +// disable the geoservice, TODO don't know if I want this +//user_pref("geo.provider.use_geoclue", false); // 0202 + +// TODO is this something useful? +user_pref("datareporting.policy.dataSubmissionEnabled", true); // 0330 + +// enable health reports +user_pref("datareporting.healthreport.uploadEnabled", true); // 0331 + +// Do I want to opt-out? +user_pref("toolkit.telemetry.coverage.opt-out", false); // 0333 + +// enables studies +user_pref("app.shield.optoutstudies.enabled", true); // 0340 + +// I guess that browsing protection is useful +user_pref("browser.safebrowsing.downloads.remote.enabled", true); // 0403 + +// TODO does this (-> set to false) make things slower? +user_pref("network.prefetch-next", true); // 0601 + +// enable ipv6 because the rest of the system uses it +user_pref("network.dns.disableIPv6", false); // 0701 + +// TRR only +user_pref("network.trr.mode", 3); // 0710 + +// I trust my search engine +user_pref("keyword.enabled", true); // 801 +user_pref("browser.search.suggest.enabled", true); // 0804 +user_pref("browser.urlbar.suggest.searches", true); // 0804 + +// prefetch urls, if the get auto completed +user_pref("browser.urlbar.speculativeConnect.enabled", true); // 0805 + +// TODO I might want to enable this +//user_pref("browser.urlbar.suggest.quicksuggest.nonsponsored", false); // 0807 + +// TODO enable form and search history? +//user_pref("browser.formfill.enable", false); // 0810 + +// disk cache should help performance +user_pref("browser.cache.disk.enable", true); // 1001 + +// store extra session data (form content, cookies and POST data) 0: everywhere +user_pref("browser.sessionstore.privacy_level", 0); // 1003 + +// Disable unsafe passive content (images) on https sites +user_pref("security.mixed_content.block_display_content", true); // 1241 + +// Disable the eme banner +user_pref("browser.eme.ui.enabled", false); // 2022 + +// Don't delete my precious temp files +user_pref("browser.helperApps.deleteTempFileOnExit", false); // 2603 + +// Download to the download dir +user_pref("browser.download.useDownloadDir", true); // 2651 + +// Open the download panel +user_pref("browser.download.alwaysOpenPanel", true); // 2652 + +// Block after custom ruleset +user_pref("browser.contentblocking.category", "custom"); // 2701 + +// set the custome settings // 7016 +user_pref("network.cookie.cookieBehavior", 1); +user_pref("network.http.referer.disallowCrossSiteRelaxingDefault", true); +user_pref("network.http.referer.disallowCrossSiteRelaxingDefault.top_navigation", true); +user_pref("privacy.partition.network_state.ocsp_cache", true); +user_pref("privacy.query_stripping.enabled", true); +user_pref("privacy.trackingprotection.enabled", true); +user_pref("privacy.trackingprotection.socialtracking.enabled", true); +user_pref("privacy.trackingprotection.cryptomining.enabled", true); +user_pref("privacy.trackingprotection.fingerprinting.enabled", true); + + +// I might want to change that, when it hinders session restore +//user_pref("privacy.partition.always_partition_third_party_non_cookie_storage.exempt_sessionstorage", false); // 2720 + +// I like my history very much! +user_pref("privacy.sanitize.sanitizeOnShutdown", false); // 2810 + +// The downsides (light theme + potential breakages): +//user_pref("privacy.resistFingerprinting", true); // 4501 +user_pref("privacy.resistFingerprinting.letterboxing", false); // 4504 + +// I would like to keep my gl, even in the web +user_pref("webgl.disabled", false); // 4520 + +// I like my service workers and am using a service using them. +user_pref("dom.serviceWorkers.enabled", true); // 7017 + +// I've got a password manager already +user_pref("signon.rememberSignons", false); // 5003 + +// Do not track header +user_pref("privacy.donottrackheader.enabled", true); // 7015 + +// TODO no idea what this does, enabling it +user_pref("browser.urlbar.showSearchTerms.enabled", true); // 9004 diff --git a/home-manager/config/firefox/config/search/engines/default.nix b/home-manager/config/firefox/config/search/engines/default.nix new file mode 100644 index 00000000..286d7247 --- /dev/null +++ b/home-manager/config/firefox/config/search/engines/default.nix @@ -0,0 +1,59 @@ +{pkgs, ...}: { + "Brave Search" = { + urls = [{template = "https://search.brave.com/search?q={searchTerms}";}]; + IconUpdateURL = "https://raw.githubusercontent.com/brave/brave-core/master/components/brave_welcome_ui/components/images/lion_logo.svg"; + updateInterval = 24; # every day + definedAliases = ["@bs"]; + }; + + # NIX + "Nix Packages" = { + urls = [{template = "https://search.nixos.org/packages?type=packages&query={searchTerms}";}]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = ["@np"]; + }; + "Nix Options" = { + urls = [{template = "https://search.nixos.org/options?type=options&query={searchTerms}";}]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = ["@no"]; + }; + "NixOS Wiki" = { + urls = [{template = "https://nixos.wiki/index.php?search={searchTerms}";}]; + icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; + definedAliases = ["@nw"]; + }; + + "Arch Wiki" = { + urls = [{template = "https://wiki.archlinux.org/index.php?search={searchTerms}";}]; + iconUpdateURL = "https://upload.wikimedia.org/wikipedia/commons/a/a5/Archlinux-icon-crystal-64.svg"; + updateInterval = 24; + definedAliases = ["@aw"]; + }; + + # RUST + "Rust std" = { + urls = [{template = "https://doc.rust-lang.org/std/?search={searchTerms}";}]; + iconUpdateURL = "https://rustacean.net/assets/rustacean-orig-noshadow.svg"; + updateInterval = 24; + definedAliases = ["@rs"]; + }; + + "Google Scholar" = { + urls = [{template = "https://scholar.google.com/scholar?hl=en&q={searchTerms}";}]; + iconUpdateURL = "https://scholar.google.com/favicon.ico"; + updateInterval = 24; + definedAliases = ["@gs"]; + }; + "Wikipedia" = { + urls = [{template = "https://en.wikipedia.org/wiki/{searchTerms}";}]; + iconUpdateURL = "https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg"; + updateInterval = 24; + definedAliases = ["@wp"]; + }; + + "Wikipedia (en)".metaData.hidden = true; + "DuckDuckGo".metaData.hidden = true; + "Bing".metaData.hidden = true; + "Google".metaData.hidden = true; + "Amazon.de".metaData.hidden = true; +} diff --git a/home-manager/config/firefox/default.nix b/home-manager/config/firefox/default.nix index 611f594c..0b98f5d6 100644 --- a/home-manager/config/firefox/default.nix +++ b/home-manager/config/firefox/default.nix @@ -7,192 +7,21 @@ video_pause, ... }: let - bookmarks = [ - { - name = "Feed - Piped"; - url = "https://piped.video/feed"; - } + userChrome = builtins.readFile ./config/chrome/userChrome.css; - { - name = "DeepL Translate"; - url = "https://www.deepl.com/translator#en/de/test"; - } - - { - name = "HM Options"; - url = "https://mipmip.github.io/home-manager-option-search/"; - } - ]; - firefoxBookmarksFile = bookmarks: let - indent = level: - lib.concatStringsSep "" (map (lib.const " ") (lib.range 1 level)); - - bookmarkToHTML = indentLevel: bookmark: '' - ${indent indentLevel}
${lib.escapeXML bookmark.name}''; - - directoryToHTML = indentLevel: directory: '' - ${indent indentLevel}
${ - if directory.toolbar - then ''

Bookmarks Toolbar'' - else "

${lib.escapeXML directory.name}" - }

- ${indent indentLevel}

- ${allItemsToHTML (indentLevel + 1) directory.bookmarks} - ${indent indentLevel}

''; - - itemToHTMLOrRecurse = indentLevel: item: - if item ? "url" - then bookmarkToHTML indentLevel item - else directoryToHTML indentLevel item; - - allItemsToHTML = indentLevel: bookmarks: - lib.concatStringsSep "\n" - (map (itemToHTMLOrRecurse indentLevel) bookmarks); - - bookmarkEntries = allItemsToHTML 1 bookmarks; - in - pkgs.writeText "firefox-bookmarks.html" '' - - - - Bookmarks -

Bookmarks Menu

- -

-

Bookmarks Toolbar

-

- ${bookmarkEntries} -

-

- ''; - userChrome = builtins.readFile ./chrome/userChrome.css; - - user_js_override = pkgs.writeText "user.override.js" (builtins.readFile ./settings/override.js); - user_js_nix = pkgs.runCommand "user.js" {} '' - mkdir $out; - cat "${user_js}/user.js" > $out/user.js; - cat "${user_js_override}" >> $out/user.js; - - cat << EOF >> $out/user.js; - // My bookmarks - user_pref("browser.bookmarks.file", "${toString (firefoxBookmarksFile bookmarks)}"); - user_pref("browser.places.importBookmarksHTML", true); - - // Allow my custom css - user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true); - - // might improve performance TODO - user_pref("gfx.webrender.all", true); - - // disable updates (pretty pointless with nix) - user_pref("extensions.update.autoUpdateDefault", false); - user_pref("extensions.update.enabled", false); - user_pref("app.update.channel", "default"); - - user_pref("browser.ctrlTab.recentlyUsedOrder", false); - - user_pref("browser.download.useDownloadDir", true); - user_pref("browser.download.dir", "${config.home.homeDirectory}/media/downloads"); - user_pref("browser.download.folderList", 2); # TODO - user_pref("browser.download.viewableInternally.typeWasRegistered.svg", true); - user_pref("browser.download.viewableInternally.typeWasRegistered.webp", true); - user_pref("browser.download.viewableInternally.typeWasRegistered.xml", true); - - // TODO what does this do? - user_pref("browser.search.widget.inNavBar", true); - - user_pref("browser.shell.checkDefaultBrowser", false); - user_pref("browser.tabs.loadInBackground", true); - user_pref("browser.urlbar.placeholderName", "Brave"); - - // Set the tabs and bookmarks - user_pref("browser.tabs.inTitlebar", 1); - user_pref("browser.toolbars.bookmarks.visibility", "always"); - - // Theme - user_pref("extensions.activeThemeID", "firefox-alpenglow@mozilla.org"); - user_pref("extensions.extensions.activeThemeID", "firefox-alpenglow@mozilla.org"); - - // highlight all entries when searching - user_pref("findbar.highlightAll", true); - - // TODO - //user_pref("extensions.webcompat.enable_picture_in_picture_overrides", true); - //user_pref("extensions.webcompat.enable_shims", true); - //user_pref("extensions.webcompat.perform_injections", true); - //user_pref("extensions.webcompat.perform_ua_overrides", true); - - // onlykey / copied from a yubikey config - //user_pref("security.webauth.u2f", true); - //user_pref("security.webauth.webauthn", true); - //user_pref("security.webauth.webauthn_enable_softtoken", true); - //user_pref("security.webauth.webauthn_enable_usbtoken", true); - EOF - ''; + user_js_nix = (import ./config/prefs) {inherit pkgs lib config user_js;}; extensions = builtins.map buildFirefoxXpiAddon ( lib.attrValues ( - lib.importJSON ./settings/extensions.json + lib.importJSON ./config/extensions/extensions.json ) ); + engines = (import ./config/search/engines) {inherit pkgs;}; # source: https://gitlab.com/rycee/nur-expressions/-/blob/master/pkgs/firefox-addons/default.nix - buildFirefoxXpiAddon = { - pname, - version, - addonId, - url, - sha256, - #meta, - ... - }: - pkgs.stdenv.mkDerivation { - name = "${pname}-${version}"; - - #inherit meta; - - src = builtins.fetchurl {inherit url sha256;}; - - preferLocalBuild = true; - allowSubstitutes = true; - - buildCommand = '' - dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" - mkdir -p "$dst" - install -v -m644 "$src" "$dst/${addonId}.xpi" - ''; - }; + buildFirefoxXpiAddon = (import ./functions/extensions) {inherit pkgs;}; - settings = {}; - video-pauser = pkgs.runCommand "video_pause_native_messaging" {} '' - install -d $out/share/ - cat << EOF > $out/share/video_pauser.json - { - "name": "video_pauser", - "description": "Pause your Videos with a single key stroke!", - "path": "${video_pause}/bin/video_pause", - "type": "stdio", - "allowed_extensions": ["video-pauser@addons.vhack.eu"] - } - EOF - - nativeMessagingPaths=( - /lib/mozilla/native-messaging-hosts - /etc/opt/chrome/native-messaging-hosts - /etc/chromium/native-messaging-hosts - /etc/vivaldi/native-messaging-hosts - /lib/librewolf/native-messaging-hosts - ) - - for manifestDir in "''${nativeMessagingPaths[@]}"; do - install -d $out$manifestDir - ln -s $out/share/video_pauser.json $out$manifestDir/ - done - ''; + video-pauser = (import ./functions/extensions/video-pauser.nix) {inherit pkgs video_pause;}; in { home.sessionVariables = { # improve touch input & make scrolling smother @@ -227,69 +56,10 @@ in { default = "Brave Search"; force = true; - engines = { - "Brave Search" = { - urls = [{template = "https://search.brave.com/search?q={searchTerms}";}]; - iconUpdateURL = "https://raw.githubusercontent.com/brave/brave-core/master/components/brave_welcome_ui/components/images/lion_logo.svg"; - updateInterval = 24; # every day - definedAliases = ["@bs"]; - }; - - # NIX - "Nix Packages" = { - urls = [{template = "https://search.nixos.org/packages?type=packages&query={searchTerms}";}]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - definedAliases = ["@np"]; - }; - "Nix Options" = { - urls = [{template = "https://search.nixos.org/options?type=options&query={searchTerms}";}]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - definedAliases = ["@no"]; - }; - "NixOS Wiki" = { - urls = [{template = "https://nixos.wiki/index.php?search={searchTerms}";}]; - icon = "${pkgs.nixos-icons}/share/icons/hicolor/scalable/apps/nix-snowflake.svg"; - definedAliases = ["@nw"]; - }; - - "Arch Wiki" = { - urls = [{template = "https://wiki.archlinux.org/index.php?search={searchTerms}";}]; - iconUpdateURL = "https://upload.wikimedia.org/wikipedia/commons/a/a5/Archlinux-icon-crystal-64.svg"; - updateInterval = 24; - definedAliases = ["@aw"]; - }; - - # RUST - "Rust std" = { - urls = [{template = "https://doc.rust-lang.org/std/?search={searchTerms}";}]; - iconUpdateURL = "https://rustacean.net/assets/rustacean-orig-noshadow.svg"; - updateInterval = 24; - definedAliases = ["@rs"]; - }; - - "Google Scholar" = { - urls = [{template = "https://scholar.google.com/scholar?hl=en&q={searchTerms}";}]; - iconUpdateURL = "https://scholar.google.com/favicon.ico"; - updateInterval = 24; - definedAliases = ["@gs"]; - }; - "Wikipedia" = { - urls = [{template = "https://en.wikipedia.org/wiki/{searchTerms}";}]; - iconUpdateURL = "https://upload.wikimedia.org/wikipedia/en/8/80/Wikipedia-logo-v2.svg"; - updateInterval = 24; - definedAliases = ["@wp"]; - }; - - "Wikipedia (en)".metaData.hidden = true; - "DuckDuckGo".metaData.hidden = true; - "Bing".metaData.hidden = true; - "Google".metaData.hidden = true; - "Amazon.de".metaData.hidden = true; - }; + inherit engines; }; bookmarks = []; - inherit settings; extraConfig = builtins.readFile "${user_js_nix}/user.js"; }; }; diff --git a/home-manager/config/firefox/functions/bookmarks/default.nix b/home-manager/config/firefox/functions/bookmarks/default.nix new file mode 100644 index 00000000..d1d89dd2 --- /dev/null +++ b/home-manager/config/firefox/functions/bookmarks/default.nix @@ -0,0 +1,49 @@ +{ + lib, + pkgs, +}: bookmarks: let + indent = level: + lib.concatStringsSep "" (map (lib.const " ") (lib.range 1 level)); + + bookmarkToHTML = indentLevel: bookmark: '' + ${indent indentLevel}
${lib.escapeXML bookmark.name}''; + + directoryToHTML = indentLevel: directory: '' + ${indent indentLevel}
${ + if directory.toolbar + then ''

Bookmarks Toolbar'' + else "

${lib.escapeXML directory.name}" + }

+ ${indent indentLevel}

+ ${allItemsToHTML (indentLevel + 1) directory.bookmarks} + ${indent indentLevel}

''; + + itemToHTMLOrRecurse = indentLevel: item: + if item ? "url" + then bookmarkToHTML indentLevel item + else directoryToHTML indentLevel item; + + allItemsToHTML = indentLevel: bookmarks: + lib.concatStringsSep "\n" + (map (itemToHTMLOrRecurse indentLevel) bookmarks); + + bookmarkEntries = allItemsToHTML 1 bookmarks; +in + pkgs.writeText "firefox-bookmarks.html" '' + + + + Bookmarks +

Bookmarks Menu

+ +

+

Bookmarks Toolbar

+

+ ${bookmarkEntries} +

+

+ '' diff --git a/home-manager/config/firefox/functions/extensions/default.nix b/home-manager/config/firefox/functions/extensions/default.nix new file mode 100644 index 00000000..e3373d86 --- /dev/null +++ b/home-manager/config/firefox/functions/extensions/default.nix @@ -0,0 +1,26 @@ +# vim: ts=2 +{pkgs, ...}: { + pname, + version, + addonId, + url, + sha256, + #meta, + ... +}: +pkgs.stdenv.mkDerivation { + name = "${pname}-${version}"; + + #inherit meta; + + src = builtins.fetchurl {inherit url sha256;}; + + preferLocalBuild = true; + allowSubstitutes = true; + + buildCommand = '' + dst="$out/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" + mkdir -p "$dst" + install -v -m644 "$src" "$dst/${addonId}.xpi" + ''; +} diff --git a/home-manager/config/firefox/functions/extensions/video-pauser.nix b/home-manager/config/firefox/functions/extensions/video-pauser.nix new file mode 100644 index 00000000..a6b0e838 --- /dev/null +++ b/home-manager/config/firefox/functions/extensions/video-pauser.nix @@ -0,0 +1,31 @@ +# vim: ts=2 +{ + pkgs, + video_pause, + ... +}: +pkgs.runCommand "video_pause_native_messaging" {} '' + install -d $out/share/ + cat << EOF > $out/share/video_pauser.json + { + "name": "video_pauser", + "description": "Pause your Videos with a single key stroke!", + "path": "${video_pause}/bin/video_pause", + "type": "stdio", + "allowed_extensions": ["video-pauser@addons.vhack.eu"] + } + EOF + + nativeMessagingPaths=( + /lib/mozilla/native-messaging-hosts + /etc/opt/chrome/native-messaging-hosts + /etc/chromium/native-messaging-hosts + /etc/vivaldi/native-messaging-hosts + /lib/librewolf/native-messaging-hosts + ) + + for manifestDir in "''${nativeMessagingPaths[@]}"; do + install -d $out$manifestDir + ln -s $out/share/video_pauser.json $out$manifestDir/ + done +'' diff --git a/home-manager/config/firefox/scripts/update_extensions b/home-manager/config/firefox/scripts/update_extensions index b743f4f1..2c532387 100755 --- a/home-manager/config/firefox/scripts/update_extensions +++ b/home-manager/config/firefox/scripts/update_extensions @@ -15,7 +15,7 @@ cat << EOF > $tmp EOF -nix shell git+https://codeberg.org/ene/generate_moz_extension.git -c generate_extensions $(cat $tmp) > "$(dirname $0)"/../settings/extensions.json +nix shell git+https://codeberg.org/ene/generate_moz_extension.git -c generate_extensions $(cat $tmp) > "$(dirname $0)"/../config/extensions/extensions.json diff --git a/home-manager/config/firefox/settings/extensions.json b/home-manager/config/firefox/settings/extensions.json deleted file mode 100644 index 1de32896..00000000 --- a/home-manager/config/firefox/settings/extensions.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "darkreader": { - "addonId": "addon@darkreader.org", - "pname": "darkreader", - "sha256": "sha256:16ba6337fcff7ad85e08ad51b384ba26ff751b2b2ded12309f75e8337ace925a", - "url": "https://addons.mozilla.org/firefox/downloads/file/4095037/darkreader-4.9.63.xpi", - "version": "4.9.63" - }, - "keepassxc-browser": { - "addonId": "keepassxc-browser@keepassxc.org", - "pname": "keepassxc-browser", - "sha256": "sha256:ce2275eb1f0a4b0ce2342204d00d62033f81f6dcb9e021cff38f51273e614f20", - "url": "https://addons.mozilla.org/firefox/downloads/file/4094964/keepassxc_browser-1.8.6.1.xpi", - "version": "1.8.6.1" - }, - "libredirect": { - "addonId": "7esoorv3@alefvanoon.anonaddy.me", - "pname": "libredirect", - "sha256": "sha256:57d6adbaabf74f386be88d63906992be46cf77c485c1c00afa27161ef3bbb8d4", - "url": "https://addons.mozilla.org/firefox/downloads/file/4079849/libredirect-2.5.4.xpi", - "version": "2.5.4" - }, - "simple-tab-groups": { - "addonId": "simple-tab-groups@drive4ik", - "pname": "simple-tab-groups", - "sha256": "sha256:2e955a41bafc01315ad435160e5be25a3b91d06555fba8097acc8b396b4df69c", - "url": "https://addons.mozilla.org/firefox/downloads/file/4098262/simple_tab_groups-5.1.xpi", - "version": "5.1" - }, - "tridactyl-vim": { - "addonId": "tridactyl.vim@cmcaine.co.uk", - "pname": "tridactyl-vim", - "sha256": "sha256:08b7af97bef05300ab3ac3ad721322ff00505631233482568fc4489c16d51b71", - "url": "https://addons.mozilla.org/firefox/downloads/file/4036604/tridactyl_vim-1.23.0.xpi", - "version": "1.23.0" - }, - "ublock-origin": { - "addonId": "uBlock0@raymondhill.net", - "pname": "ublock-origin", - "sha256": "sha256:d7666b963c2969b0014937aae55472eea5098ff21ed3bea8a2e1f595f62856c1", - "url": "https://addons.mozilla.org/firefox/downloads/file/4092158/ublock_origin-1.48.4.xpi", - "version": "1.48.4" - }, - "video-pauser": { - "addonId": "video-pauser@addons.vhack.eu", - "pname": "video-pauser", - "sha256": "sha256:da02e29f1d50d3a6db8a28bb7972afaeaa788bb8d38a2e9ebbfcd73d65d84841", - "url": "https://addons.mozilla.org/firefox/downloads/file/4098103/video_pauser-0.1.0.xpi", - "version": "0.1.0" - } -} diff --git a/home-manager/config/firefox/settings/override.js b/home-manager/config/firefox/settings/override.js deleted file mode 100644 index ca03e8ed..00000000 --- a/home-manager/config/firefox/settings/override.js +++ /dev/null @@ -1,137 +0,0 @@ -/* - 0100: STARTUP - 0200: GEOLOCATION / LANGUAGE / LOCALE - 0300: QUIETER FOX - 0400: SAFE BROWSING - 0600: BLOCK IMPLICIT OUTBOUND - 0700: DNS / DoH / PROXY / SOCKS / IPv6 - 0800: LOCATION BAR / SEARCH BAR / SUGGESTIONS / HISTORY / FORMS - 0900: PASSWORDS - 1000: DISK AVOIDANCE - 1200: HTTPS (SSL/TLS / OCSP / CERTS / HPKP) - 1400: FONTS - 1600: HEADERS / REFERERS - 1700: CONTAINERS - 2000: PLUGINS / MEDIA / WEBRTC - 2400: DOM (DOCUMENT OBJECT MODEL) - 2600: MISCELLANEOUS - 2700: ETP (ENHANCED TRACKING PROTECTION) - 2800: SHUTDOWN & SANITIZING - 4500: RFP (RESIST FINGERPRINTING) - 5000: OPTIONAL OPSEC - 5500: OPTIONAL HARDENING - 6000: DON'T TOUCH - 7000: DON'T BOTHER - 8000: DON'T BOTHER: FINGERPRINTING - 9000: NON-PROJECT RELATED - 9999: DEPRECATED / REMOVED / LEGACY / RENAMED -*/ - - -// restore session -user_pref("browser.startup.page", 3); // 0102 - -user_pref("browser.startup.homepage", "file:///home/dt/home.html"); // 0103 -user_pref("browser.newtabpage.enabled", true); // 0104 - -// disable the geoservice, TODO don't know if I want this -//user_pref("geo.provider.use_geoclue", false); // 0202 - -// TODO is this something useful? -user_pref("datareporting.policy.dataSubmissionEnabled", true); // 0330 - -// enable health reports -user_pref("datareporting.healthreport.uploadEnabled", true); // 0331 - -// Do I want to opt-out? -user_pref("toolkit.telemetry.coverage.opt-out", false); // 0333 - -// enables studies -user_pref("app.shield.optoutstudies.enabled", true); // 0340 - -// I guess that browsing protection is useful -user_pref("browser.safebrowsing.downloads.remote.enabled", true); // 0403 - -// TODO does this (-> set to false) make things slower? -user_pref("network.prefetch-next", true); // 0601 - -// enable ipv6 because the rest of the system uses it -user_pref("network.dns.disableIPv6", false); // 0701 - -// TRR only -user_pref("network.trr.mode", 3); // 0710 - -// I trust my search engine -user_pref("keyword.enabled", true); // 801 -user_pref("browser.search.suggest.enabled", true); // 0804 -user_pref("browser.urlbar.suggest.searches", true); // 0804 - -// prefetch urls, if the get auto completed -user_pref("browser.urlbar.speculativeConnect.enabled", true); // 0805 - -// TODO I might want to enable this -//user_pref("browser.urlbar.suggest.quicksuggest.nonsponsored", false); // 0807 - -// TODO enable form and search history? -//user_pref("browser.formfill.enable", false); // 0810 - -// disk cache should help performance -user_pref("browser.cache.disk.enable", true); // 1001 - -// store extra session data (form content, cookies and POST data) 0: everywhere -user_pref("browser.sessionstore.privacy_level", 0); // 1003 - -// Disable unsafe passive content (images) on https sites -user_pref("security.mixed_content.block_display_content", true); // 1241 - -// Disable the eme banner -user_pref("browser.eme.ui.enabled", false); // 2022 - -// Don't delete my precious temp files -user_pref("browser.helperApps.deleteTempFileOnExit", false); // 2603 - -// Download to the download dir -user_pref("browser.download.useDownloadDir", true); // 2651 - -// Open the download panel -user_pref("browser.download.alwaysOpenPanel", true); // 2652 - -// Block after custom ruleset -user_pref("browser.contentblocking.category", "custom"); // 2701 - -// set the custome settings // 7016 -user_pref("network.cookie.cookieBehavior", 1); -user_pref("network.http.referer.disallowCrossSiteRelaxingDefault", true); -user_pref("network.http.referer.disallowCrossSiteRelaxingDefault.top_navigation", true); -user_pref("privacy.partition.network_state.ocsp_cache", true); -user_pref("privacy.query_stripping.enabled", true); -user_pref("privacy.trackingprotection.enabled", true); -user_pref("privacy.trackingprotection.socialtracking.enabled", true); -user_pref("privacy.trackingprotection.cryptomining.enabled", true); -user_pref("privacy.trackingprotection.fingerprinting.enabled", true); - - -// I might want to change that, when it hinders session restore -//user_pref("privacy.partition.always_partition_third_party_non_cookie_storage.exempt_sessionstorage", false); // 2720 - -// I like my history very much! -user_pref("privacy.sanitize.sanitizeOnShutdown", false); // 2810 - -// The downsides (light theme + potential breakages): -//user_pref("privacy.resistFingerprinting", true); // 4501 -user_pref("privacy.resistFingerprinting.letterboxing", false); // 4504 - -// I would like to keep my gl, even in the web -user_pref("webgl.disabled", false); // 4520 - -// I like my service workers and am using a service using them. -user_pref("dom.serviceWorkers.enabled", true); // 7017 - -// I've got a password manager already -user_pref("signon.rememberSignons", false); // 5003 - -// Do not track header -user_pref("privacy.donottrackheader.enabled", true); // 7015 - -// TODO no idea what this does, enabling it -user_pref("browser.urlbar.showSearchTerms.enabled", true); // 9004 -- cgit 1.4.1