From 527374059e9ffe803639b29f83856e2c75b48886 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Tue, 17 Nov 2026 00:29:59 -0500 Subject: [PATCH] add librewolf mobile config --- flake.lock | 8 ++-- modules/graphical/librewolf/customChrome.css | 8 ++++ modules/graphical/librewolf/default.nix | 8 +--- modules/mobile/librewolf.nix | 40 ++++++++++++++++++++ 4 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 modules/mobile/librewolf.nix diff --git a/flake.lock b/flake.lock index 52cb2cd..4c1f8c4 100644 --- a/flake.lock +++ b/flake.lock @@ -81,11 +81,11 @@ ] }, "locked": { - "lastModified": 1794892328, - "narHash": "sha256-9QMpzIs+e2zhK62ErBzi6sHOwKtUM2cAiMOuRVPxbE8=", + "lastModified": 1794892850, + "narHash": "sha256-7kOT7EWzzNnKvuuPkTx9HciJ7Kd1ZrUbZJcwKgqq+w0=", "ref": "refs/heads/main", - "rev": "42d273798b72ab517413738c323164382d74b3d3", - "revCount": 3, + "rev": "ab0704e682c8b394edbec55c2b7b83d1601f7da8", + "revCount": 4, "type": "git", "url": "https://git.federated.nexus/Henry-Hiles/app-grid" }, diff --git a/modules/graphical/librewolf/customChrome.css b/modules/graphical/librewolf/customChrome.css index 0760c97..2abac59 100644 --- a/modules/graphical/librewolf/customChrome.css +++ b/modules/graphical/librewolf/customChrome.css @@ -134,3 +134,11 @@ --gnome-private-text-primary-color: #fbfbfe; } } + +/* Phone only: quad.mobile is set in modules/mobile/librewolf.nix. The mobile layout turns the URL + * bar results into a sheet over the page, but the theme makes its background transparent. */ +@media -moz-pref("quad.mobile") { + .urlbarView { + background: var(--gnome-menu-background) !important; + } +} diff --git a/modules/graphical/librewolf/default.nix b/modules/graphical/librewolf/default.nix index 94784ba..cc8d4c8 100644 --- a/modules/graphical/librewolf/default.nix +++ b/modules/graphical/librewolf/default.nix @@ -133,6 +133,8 @@ value = { install_url = "https://addons.mozilla.org/en-US/firefox/downloads/latest/${id}/latest.xpi"; installation_mode = "force_installed"; + # In the extensions menu, not as separate toolbar buttons + default_area = "menupanel"; }; }) [ @@ -141,15 +143,9 @@ "sponsorBlocker@ajay.app" "firefox@tampermonkey.net" "firefox-addon@pronoundb.org" - "jid1-MnnxcxisBPnSXQ@jetpack" # Privacy Badger "frankerfacez@frankerfacez.com" - "7esoorv3@alefvanoon.anonaddy.me" # LibRedirect "{de621c74-2aa6-4c91-a2da-28d445b66bab}" # YouTube Livestreams Theater Mode - "{cf3dba12-a848-4f68-8e2d-f9fadc0721de}" # Google Lighthouse "{446900e4-71c2-419f-a6a7-df9c091e268b}" # Bitwarden - "{4ce83447-8255-43c2-b8f7-e02eb8c2cc39}" # Draw on Page - "{ac34afe8-3a2e-4201-b745-346c0cf6ec7d}" # Better Youtube Shorts - "{a6c4a591-f1b2-4f03-b3ff-767e5bedf4e7}" # User-Agent Switcher and Manager "enhancerforyoutube@maximerf.addons.mozilla.org" ] ) diff --git a/modules/mobile/librewolf.nix b/modules/mobile/librewolf.nix new file mode 100644 index 0000000..0af0b12 --- /dev/null +++ b/modules/mobile/librewolf.nix @@ -0,0 +1,40 @@ +{ pkgs, ... }: +# The mobile layout from postmarketOS's mobile-config-firefox, the same way nixpkgs' firefox-mobile +# adds it, but on top of the LibreWolf set up in graphical/librewolf. +let + src = pkgs.fetchFromGitLab { + domain = "gitlab.nura.eco"; + owner = "nura"; + repo = "mobile-config-firefox"; + rev = "5.5.1"; + hash = "sha256-kIMeVKUI8/MdCJIkBlcYYEUnN7+ciDpKuReAeKkn8VY="; + }; + + configDir = pkgs.runCommand "mobile-config-firefox" { } '' + mkdir -p $out + cp -r ${src}/src/modules/. $out/ + cp -r ${src}/src/themes $out/ + ''; + + # It logs into /chrome, which is a read-only theme from the store here, and failing to + # open the log stops it from loading at all. Log into the profile itself instead. + autoconfig = pkgs.runCommand "mobile-config-autoconfig.js" { } '' + substitute ${src}/src/mobile-config-autoconfig.js $out \ + --replace-fail "/usr/lib/mobile-config-firefox" "${configDir}" \ + --replace-fail 'var logFile = g_chromeDir.clone();' 'var logFile = Services.dirsvc.get("ProfD", Ci.nsIFile);' + ''; + + # The wrapper sets up autoconfig itself + prefs = pkgs.runCommand "mobile-config-prefs.js" { } '' + grep -v -e general.config.filename -e general.config.obscure_value \ + -e general.config.sandbox_enabled ${src}/src/mobile-config-prefs.js > $out + ''; +in +{ + programs.firefox.autoConfigFiles = [ + autoconfig + prefs + # Lets graphical/librewolf/customChrome.css fix things up for the mobile layout only + (pkgs.writeText "quad-mobile-prefs.js" ''defaultPref("quad.mobile", true);'') + ]; +}