@@ -1,5 +1,6 @@
11{ pname, version, updateScript ? null
2−, src, patches ? [], meta }:
2+, src, patches ? [], overrides ? {}, meta
3+, isTorBrowserLike ? false }:
34
45{ lib, stdenv, pkgconfig, pango, perl, python, zip, libIDL
56, libjpeg, zlib, dbus, dbus_glib, bzip2, xorg
@@ -22,12 +23,13 @@
2223
2324## privacy-related options
2425
25−, privacySupport ? false
26+, privacySupport ? isTorBrowserLike
2627
2728# WARNING: NEVER set any of the options below to `true` by default.
2829# Set to `privacySupport` or `false`.
2930
3031, webrtcSupport ? !privacySupport
32+, loopSupport ? !privacySupport || !isTorBrowserLike
3133, geolocationSupport ? !privacySupport
3234, googleAPISupport ? geolocationSupport
3335, crashreporterSupport ? false
@@ -37,21 +39,22 @@
3739
3840## other
3941
40−# If you want the resulting program to call itself "Firefox" instead
41−# of "Nightly" or whatever, enable this option. However, those
42−# binaries may not be distributed without permission from the
43−# Mozilla Foundation, see
42+# If you want the resulting program to call itself
43+# "Firefox"/"Torbrowser" instead of "Nightly" or whatever, enable this
44+# option. However, in Firefox's case, those binaries may not be
45+# distributed without permission from the Mozilla Foundation, see
4446# http://www.mozilla.org/foundation/trademarks/.
4547, enableOfficialBranding ? false
4648}:
4749
4850assert stdenv.cc ? libc && stdenv.cc.libc != null;
51+assert !isTorBrowserLike -> loopSupport; # can't be disabled on firefox :(
4952
5053let
5154 flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")];
5255in
5356
54−stdenv.mkDerivation rec {
57+stdenv.mkDerivation (rec {
5558 name = "${pname}-unwrapped-${version}";
5659
5760 inherit src patches meta;
@@ -60,12 +63,14 @@ stdenv.mkDerivation rec {
6063 gtk2 perl zip libIDL libjpeg zlib bzip2
6164 dbus dbus_glib pango freetype fontconfig xorg.libXi
6265 xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
63− nss nspr libnotify xorg.pixman yasm mesa
66+ nspr libnotify xorg.pixman yasm mesa
6467 xorg.libXScrnSaver xorg.scrnsaverproto
6568 xorg.libXext xorg.xextproto sqlite unzip makeWrapper
6669 hunspell libevent libstartup_notification libvpx /* cairo */
6770 icu libpng jemalloc
6871 ]
72+ ++ lib.optionals (!isTorBrowserLike) [ nss ]
73+
6974 ++ lib.optional alsaSupport alsaLib
7075 ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
7176 ++ lib.optionals ffmpegSupport [ gstreamer gst-plugins-base ]
@@ -98,8 +103,6 @@ stdenv.mkDerivation rec {
98103 "--with-system-jpeg"
99104 "--with-system-zlib"
100105 "--with-system-bz2"
101− "--with-system-nspr"
102− "--with-system-nss"
103106 "--with-system-libevent"
104107 "--with-system-libvpx"
105108 "--with-system-png" # needs APNG support
@@ -119,11 +122,33 @@ stdenv.mkDerivation rec {
119122 "--disable-gconf"
120123 "--enable-default-toolkit=cairo-gtk${if gtk3Support then "3" else "2"}"
121124 ]
125+
126+ # TorBrowser patches these
127+ ++ lib.optionals (!isTorBrowserLike) [
128+ "--with-system-nss"
129+ "--with-system-nspr"
130+ ]
131+
132+ # and wants these
133+ ++ lib.optionals isTorBrowserLike [
134+ "--with-tor-browser-version=${version}"
135+ "--enable-signmar"
136+ "--enable-verify-mar"
137+
138+ # We opt out of TorBrowser's nspr because that patch is useless on
139+ # anything but Windows and produces zero fingerprinting
140+ # possibilities on other platforms.
141+ # Lets save some space instead.
142+ "--with-system-nspr"
143+ ]
144+
122145 ++ flag alsaSupport "alsa"
123146 ++ flag pulseaudioSupport "pulseaudio"
124147 ++ flag ffmpegSupport "ffmpeg"
125148 ++ lib.optional (!ffmpegSupport) "--disable-gstreamer"
126149 ++ flag webrtcSupport "webrtc"
150+ ++ lib.optionals isTorBrowserLike
151+ (flag loopSupport "loop")
127152 ++ flag geolocationSupport "mozril-geoloc"
128153 ++ lib.optional googleAPISupport "--with-google-api-keyfile=ga"
129154 ++ flag crashreporterSupport "crashreporter"
@@ -171,8 +196,10 @@ stdenv.mkDerivation rec {
171196 browserName = "firefox";
172197 inherit version updateScript;
173198 isFirefox3Like = true;
199+ inherit isTorBrowserLike;
174200 gtk = gtk2;
175201 inherit nspr;
176202 inherit ffmpegSupport;
177203 };
178−}
204+
205+} // overrides)