tor-browser-bundle-bin: support injecting additional prefs

The `extraPrefs` parameter is injected verbatim into the mozilla.cfg
file.

Note that the syntax is a superset of the usual prefs.js syntax.  The
following procedures are of particular interest:
pref() to set a preference as if it had been toggled in about:config
defaultPref() to set the *default* value of a preference
lockPref() to set a preference & prevent further modification
clearPref() to reset a preference to its default state

Example:
```nix
tor-browser-bundle-bin.override {
  extraPrefs = ''
    // Increase default security level
    pref("extensions.torbutton.security_slider", 2);
  '';
}
```
This commit is contained in:
Joachim Fasting 2017-07-13 09:57:10 +02:00
parent 07e492c6e6
commit 9e12be50b4
No known key found for this signature in database
GPG Key ID: 7544761007FE4E08

View File

@ -37,6 +37,9 @@
# Pluggable transport dependencies # Pluggable transport dependencies
, python27 , python27
# Extra preferences
, extraPrefs ? ""
}: }:
with stdenv.lib; with stdenv.lib;
@ -197,6 +200,10 @@ stdenv.mkDerivation rec {
// Defaults to creating $TBB_HOME/TorBrowser/Data/Tor/{socks,control}.socket // Defaults to creating $TBB_HOME/TorBrowser/Data/Tor/{socks,control}.socket
lockPref("extensions.torlauncher.control_port_use_ipc", true); lockPref("extensions.torlauncher.control_port_use_ipc", true);
lockPref("extensions.torlauncher.socks_port_use_ipc", true); lockPref("extensions.torlauncher.socks_port_use_ipc", true);
${optionalString (extraPrefs != "") ''
${extraPrefs}
''}
EOF EOF
# Hard-code path to TBB fonts; see also FONTCONFIG_FILE in # Hard-code path to TBB fonts; see also FONTCONFIG_FILE in