9 pkg = fetchFromGitLab {
10 owner = "postmarketOS";
11 repo = "mobile-config-firefox";
12 rev = "ff2f07873f4ebc6e220da0e9b9f04c69f451edda";
13 sha256 = "sha256-8wRz8corz00+0qROMiOmZAddM4tjfmE91bx0+P8JNx4=";
15 userChrome = runCommand "userChrome.css" { } ''
16 cat ${pkg}/src/userChrome/*.css > $out
18 userContent = runCommand "userContent.css" { } ''
19 cat ${pkg}/src/userContent/*.css > $out
22 wrapFirefox firefox-unwrapped {
23 # extraPolicies = (lib.importJSON "${pkg}/src/policies.json").policies;
24 extraPoliciesFiles = [ "${pkg}/src/policies.json" ];
26 // Copyright 2022 Arnaud Ferraris, Oliver Smith
27 // SPDX-License-Identifier: MPL-2.0
29 // This is a Firefox autoconfig file:
30 // https://support.mozilla.org/en-US/kb/customizing-firefox-using-autoconfig
32 // Import custom userChrome.css on startup or new profile creation
33 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
34 Cu.import("resource://gre/modules/Services.jsm");
35 Cu.import("resource://gre/modules/FileUtils.jsm");
39 // Create <profile>/chrome/ directory if not already present
40 var chromeDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
41 chromeDir.append("chrome");
42 if (!chromeDir.exists()) {
43 chromeDir.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
46 // Create nsIFile objects for userChrome.css in <profile>/chrome/ and in /etc/
47 var chromeFile = chromeDir.clone();
48 chromeFile.append("userChrome.css");
49 var defaultChrome = new FileUtils.File("${userChrome}");
51 // No auto-upgrade. Should this be replaced with symlinking?
52 // // Remove the existing userChrome.css if older than the installed one
53 // if (chromeFile.exists() && defaultChrome.exists() &&
54 // chromeFile.lastModifiedTime < defaultChrome.lastModifiedTime) {
55 // chromeFile.remove(false);
58 // Copy userChrome.css to <profile>/chrome/
59 if (!chromeFile.exists()) {
60 defaultChrome.copyTo(chromeDir, "userChrome.css");
64 // Create nsIFile objects for userContent.css in <profile>/chrome/ and in /etc/
65 var contentFile = chromeDir.clone();
66 contentFile.append("userContent.css");
67 var defaultContent = new FileUtils.File("${userContent}");
69 // No auto-upgrade. Should this be replaced with symlinking?
70 // // Remove the existing userContent.css if older than the installed one
71 // if (contentFile.exists() && defaultContent.exists() &&
72 // contentFile.lastModifiedTime < defaultContent.lastModifiedTime) {
73 // contentFile.remove(false);
76 // Copy userContent.css to <profile>/chrome/
77 if (!contentFile.exists()) {
78 defaultContent.copyTo(chromeDir, "userContent.css");
82 // Restart Firefox immediately if one of the files got updated
83 if (updated === true) {
84 var appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
85 appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
88 defaultPref('general.useragent.override', 'Mozilla/5.0 (Android 11; Mobile; rv:96.0) Gecko/96.0 Firefox/96.0');
89 defaultPref('browser.urlbar.suggest.topsites', false);
90 defaultPref('browser.urlbar.suggest.engines', false);
91 defaultPref('browser.newtabpage.enabled', true);
93 // Enable android-style pinch-to-zoom
94 pref('dom.w3c.touch_events.enabled', true);
95 pref('apz.allow_zooming', true);
96 pref('apz.allow_double_tap_zooming', true);
98 // Save vertical space by hiding the titlebar
99 pref('browser.tabs.inTitlebar', 1);
101 // Disable search suggestions
102 pref('browser.search.suggest.enabled', false);
104 // Empty new tab page: faster, less distractions
105 pref('browser.newtabpage.enabled', false);
107 // Allow UI customizations with userChrome.css and userContent.css
108 pref('toolkit.legacyUserProfileCustomizations.stylesheets', true);
110 // Select the entire URL with one click
111 pref('browser.urlbar.clickSelectsAll', true);
113 // Disable cosmetic animations, save CPU
114 pref('toolkit.cosmeticAnimations.enabled', false);
116 // Disable download animations, save CPU
117 pref('browser.download.animateNotifications', false);