@@ -1,5 +1,6 @@
1{ pname, version, updateScript ? null
1{ pname, version, updateScript ? null
2−, src, patches ? [], meta }:
2+, src, patches ? [], overrides ? {}, meta
3+, isTorBrowserLike ? false }:
4{ lib, stdenv, pkgconfig, pango, perl, python, zip, libIDL
5{ lib, stdenv, pkgconfig, pango, perl, python, zip, libIDL
5, libjpeg, zlib, dbus, dbus_glib, bzip2, xorg
6, libjpeg, zlib, dbus, dbus_glib, bzip2, xorg
@@ -22,12 +23,13 @@
23## privacy-related options
24## privacy-related options
25−, privacySupport ? false
26+, privacySupport ? isTorBrowserLike
27# WARNING: NEVER set any of the options below to `true` by default.
28# WARNING: NEVER set any of the options below to `true` by default.
28# Set to `privacySupport` or `false`.
29# Set to `privacySupport` or `false`.
30, webrtcSupport ? !privacySupport
31, webrtcSupport ? !privacySupport
32+, loopSupport ? !privacySupport || !isTorBrowserLike
31, geolocationSupport ? !privacySupport
33, geolocationSupport ? !privacySupport
32, googleAPISupport ? geolocationSupport
34, googleAPISupport ? geolocationSupport
33, crashreporterSupport ? false
35, crashreporterSupport ? false
@@ -37,21 +39,22 @@
40−# If you want the resulting program to call itself "Firefox" instead
42+# If you want the resulting program to call itself
41−# of "Nightly" or whatever, enable this option. However, those
43+# "Firefox"/"Torbrowser" instead of "Nightly" or whatever, enable this
44+# option. However, in Firefox's case, those binaries may not be
42−# binaries may not be distributed without permission from the
45+# distributed without permission from the Mozilla Foundation, see
43−# Mozilla Foundation, see
44# http://www.mozilla.org/foundation/trademarks/.
46# http://www.mozilla.org/foundation/trademarks/.
45, enableOfficialBranding ? false
47, enableOfficialBranding ? false
48assert stdenv.cc ? libc && stdenv.cc.libc != null;
50assert stdenv.cc ? libc && stdenv.cc.libc != null;
51+assert !isTorBrowserLike -> loopSupport; # can't be disabled on firefox :(
51 flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")];
54 flag = tf: x: [(if tf then "--enable-${x}" else "--disable-${x}")];
54−stdenv.mkDerivation rec {
57+stdenv.mkDerivation (rec {
55 name = "${pname}-unwrapped-${version}";
58 name = "${pname}-unwrapped-${version}";
57 inherit src patches meta;
60 inherit src patches meta;
@@ -60,12 +63,14 @@ stdenv.mkDerivation rec {
60 gtk2 perl zip libIDL libjpeg zlib bzip2
63 gtk2 perl zip libIDL libjpeg zlib bzip2
61 dbus dbus_glib pango freetype fontconfig xorg.libXi
64 dbus dbus_glib pango freetype fontconfig xorg.libXi
62 xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
65 xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
63− nss nspr libnotify xorg.pixman yasm mesa
66+ nspr libnotify xorg.pixman yasm mesa
64 xorg.libXScrnSaver xorg.scrnsaverproto
67 xorg.libXScrnSaver xorg.scrnsaverproto
65 xorg.libXext xorg.xextproto sqlite unzip makeWrapper
68 xorg.libXext xorg.xextproto sqlite unzip makeWrapper
66 hunspell libevent libstartup_notification libvpx /* cairo */
69 hunspell libevent libstartup_notification libvpx /* cairo */
67 icu libpng jemalloc
70 icu libpng jemalloc
72+ ++ lib.optionals (!isTorBrowserLike) [ nss ]
69 ++ lib.optional alsaSupport alsaLib
74 ++ lib.optional alsaSupport alsaLib
70 ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
75 ++ lib.optional pulseaudioSupport libpulseaudio # only headers are needed
71 ++ lib.optionals ffmpegSupport [ gstreamer gst-plugins-base ]
76 ++ lib.optionals ffmpegSupport [ gstreamer gst-plugins-base ]
@@ -98,8 +103,6 @@ stdenv.mkDerivation rec {
98 "--with-system-jpeg"
103 "--with-system-jpeg"
99 "--with-system-zlib"
104 "--with-system-zlib"
100 "--with-system-bz2"
105 "--with-system-bz2"
101− "--with-system-nspr"
103 "--with-system-libevent"
106 "--with-system-libevent"
104 "--with-system-libvpx"
107 "--with-system-libvpx"
105 "--with-system-png" # needs APNG support
108 "--with-system-png" # needs APNG support
@@ -119,11 +122,33 @@ stdenv.mkDerivation rec {
119 "--disable-gconf"
122 "--disable-gconf"
120 "--enable-default-toolkit=cairo-gtk${if gtk3Support then "3" else "2"}"
123 "--enable-default-toolkit=cairo-gtk${if gtk3Support then "3" else "2"}"
126+ # TorBrowser patches these
127+ ++ lib.optionals (!isTorBrowserLike) [
129+ "--with-system-nspr"
133+ ++ lib.optionals isTorBrowserLike [
134+ "--with-tor-browser-version=${version}"
136+ "--enable-verify-mar"
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"
122 ++ flag alsaSupport "alsa"
145 ++ flag alsaSupport "alsa"
123 ++ flag pulseaudioSupport "pulseaudio"
146 ++ flag pulseaudioSupport "pulseaudio"
124 ++ flag ffmpegSupport "ffmpeg"
147 ++ flag ffmpegSupport "ffmpeg"
125 ++ lib.optional (!ffmpegSupport) "--disable-gstreamer"
148 ++ lib.optional (!ffmpegSupport) "--disable-gstreamer"
126 ++ flag webrtcSupport "webrtc"
149 ++ flag webrtcSupport "webrtc"
150+ ++ lib.optionals isTorBrowserLike
151+ (flag loopSupport "loop")
127 ++ flag geolocationSupport "mozril-geoloc"
152 ++ flag geolocationSupport "mozril-geoloc"
128 ++ lib.optional googleAPISupport "--with-google-api-keyfile=ga"
153 ++ lib.optional googleAPISupport "--with-google-api-keyfile=ga"
129 ++ flag crashreporterSupport "crashreporter"
154 ++ flag crashreporterSupport "crashreporter"
@@ -171,8 +196,10 @@ stdenv.mkDerivation rec {
171 browserName = "firefox";
196 browserName = "firefox";
172 inherit version updateScript;
197 inherit version updateScript;
173 isFirefox3Like = true;
198 isFirefox3Like = true;
199+ inherit isTorBrowserLike;
174 gtk = gtk2;
200 gtk = gtk2;
175 inherit nspr;
201 inherit nspr;
176 inherit ffmpegSupport;
202 inherit ffmpegSupport;