git.iko.soy/typeable/nixpkgs
on master help sign in
tor-browser-bundle: init at 7.0.1 (from source)

The original browser bundle expects to run from a bundled directory, typically under user's home. This version creates a firefox distribution with preloaded extensions and settings that functions more like an ordinary firefox installation. The approach used here could be generalized to allow specification of custom firefox distributions. Eventually, the code will be factored so that the tbb is just an instance of that more general construct (firefox base + extensions + prefs). Currently, we use the latest upstream versions of extensions and so on. Eventually we want to track the upstream bundle more closely and ideally use the exact same inputs (firefox source, extension sources). To avoid mixing up profile data, all runtime state is stored under $XDG_DATA_HOME/tor-browser. Major TODO items - Pluggable transports - Upstream TBB version parity - Avoid fetchgit - Build NoScript from source (no upstream source repo, however, must rely on third-parties) - Improved notation for packaging extensions - Feature parity with the binary bundle (apulse and runtime purity, in particular)

commit19ecb7f287c8a85775a099aec1ce5866fefd38b9 authorJoachim Fasting <joachifm@fastmail.fm> dateTue 26 Sep 2017, 04:58 (9 years ago) parentbec98b7
2 files changed+214
pkgs/applications/networking/browsers/tor-browser-bundle/default.nix+209 pkgs/top-level/all-packages.nix+5
pkgs/applications/networking/browsers/tor-browser-bundle/default.nixnew file+209
@@ -0,0 +1,209 @@
1+{ stdenv
2+, lib
3+, fetchurl
4+, fetchgit
5+
6+, tor
7+, tor-browser-unwrapped
8+
9+# Extensions, common
10+, zip
11+
12+# HTTPS Everywhere
13+, git
14+, libxml2 # xmllint
15+, python27
16+, python27Packages
17+, rsync
18+}:
19+
20+let
21+ tor-browser-build_src = fetchgit {
22+ url = "https://git.torproject.org/builders/tor-browser-build.git";
23+ rev = "refs/tags/tbb-7.5a5-build5";
24+ sha256 = "0j37mqldj33fnzghxifvy6v8vdwkcz0i4z81prww64md5s8qcsa9";
25+ };
26+
27+ firefoxExtensions = {
28+ https-everywhere = stdenv.mkDerivation rec {
29+ name = "https-everywhere-${version}";
30+ version = "5.2.21";
31+
32+ src = fetchgit {
33+ url = "https://git.torproject.org/https-everywhere.git";
34+ rev = "refs/tags/${version}";
35+ sha256 = "0z9madihh4b4z4blvfmh6w1hsv8afyi0x7b243nciq9r4w55xgfa";
36+ };
37+
38+ nativeBuildInputs = [
39+ git
40+ libxml2 # xmllint
41+ python27
42+ python27Packages.lxml
43+ rsync
44+ zip
45+ ];
46+
47+ buildCommand = ''
48+ cp -dR --no-preserve=mode "$src" src
49+ cd src
50+
51+ sed -i makexpi.sh -e '104d' # cp -a translations/* fails because the dir is empty ...
52+ $shell ./makexpi.sh ${version} --no-recurse
53+ install -m 444 -Dt $out pkg"/"*.xpi
54+ '';
55+
56+ meta = {
57+ homepage = https://gitweb.torproject.org/https-everywhere.git/;
58+ };
59+ };
60+
61+ noscript = fetchurl {
62+ url = https://secure.informaction.com/download/releases/noscript-5.0.10.xpi;
63+ sha256 = "18k5karbaj5mhd9cyjbqgik6044bw88rjalkh6anjanxbn503j6g";
64+ };
65+
66+ torbutton = stdenv.mkDerivation rec {
67+ name = "torbutton-${version}";
68+ version = "1.9.8.1";
69+
70+ src = fetchgit {
71+ url = "https://git.torproject.org/torbutton.git";
72+ rev = "refs/tags/${version}";
73+ sha256 = "1amp0c9ky0a7fsa0bcbi6n6ginw7s2g3an4rj7kvc1lxmrcsm65l";
74+ };
75+
76+ nativeBuildInputs = [ zip ];
77+
78+ buildCommand = ''
79+ cp -dR --no-preserve=mode "$src" src
80+ cd src
81+
82+ $shell ./makexpi.sh
83+ install -m 444 -Dt $out pkg"/"*.xpi
84+ '';
85+ };
86+
87+ tor-launcher = stdenv.mkDerivation rec {
88+ name = "tor-launcher-${version}";
89+ version = "0.2.12.3";
90+
91+ src = fetchgit {
92+ url = "https://git.torproject.org/tor-launcher.git";
93+ rev = "refs/tags/${version}";
94+ sha256 = "0126x48pjiy2zm4l8jzhk70w24hviaz560ffp4lb9x0ar615bc9q";
95+ };
96+
97+ nativeBuildInputs = [ zip ];
98+
99+ buildCommand = ''
100+ cp -dR --no-preserve=mode "$src" src
101+ cd src
102+
103+ make package
104+ install -m 444 -Dt $out pkg"/"*.xpi
105+ '';
106+ };
107+ };
108+in
109+stdenv.mkDerivation rec {
110+ name = "tor-browser-bundle-${version}";
111+ version = tor-browser-unwrapped.version;
112+
113+ buildInputs = [ tor-browser-unwrapped tor ];
114+
115+ unpackPhase = ":";
116+
117+ buildPhase = ":";
118+
119+ installPhase = ''
120+ TBBUILD=${tor-browser-build_src}/projects/tor-browser
121+
122+ self=$out/lib/tor-browser
123+ mkdir -p $self && cd $self
124+
125+ cp -dR ${tor-browser-unwrapped}/lib"/"*"/"* .
126+ chmod -R +w .
127+
128+ # Prepare for autoconfig
129+ cat >defaults/pref/autoconfig.js <<EOF
130+ pref("general.config.filename", "mozilla.cfg");
131+ pref("general.config.obscure_value", 0);
132+ EOF
133+
134+ # Hardcoded configuration
135+ cat >mozilla.cfg <<EOF
136+ // First line must be a comment
137+
138+ // Always update via Nixpkgs
139+ lockPref("app.update.auto", false);
140+ lockPref("app.update.enabled", false);
141+ lockPref("extensions.update.autoUpdateDefault", false);
142+ lockPref("extensions.update.enabled", false);
143+ lockPref("extensions.torbutton.versioncheck_enabled", false);
144+
145+ // Where to find the Nixpkgs tor executable & config
146+ lockPref("extensions.torlauncher.tor_path", "${tor}/bin/tor");
147+ lockPref("extensions.torlauncher.torrc-defaults_path", "$self/torrc-defaults");
148+
149+ // Captures store paths
150+ clearPref("extensions.xpiState");
151+
152+ // Insist on using IPC for communicating with Tor
153+ //
154+ // Defaults to $XDG_RUNTIME_DIR/Tor/{socks,control}.socket
155+ lockPref("extensions.torlauncher.control_port_use_ipc", true);
156+ lockPref("extensions.torlauncher.socks_port_use_ipc", true);
157+ EOF
158+
159+ # Preload extensions
160+ install -m 444 -D \
161+ ${firefoxExtensions.tor-launcher}/tor-launcher-*.xpi \
162+ browser/extensions/tor-launcher@torproject.org.xpi
163+ install -m 444 -D \
164+ ${firefoxExtensions.torbutton}/torbutton-*.xpi \
165+ browser/extensions/torbutton@torproject.org.xpi
166+ install -m 444 -D \
167+ ${firefoxExtensions.https-everywhere}/https-everywhere-*-eff.xpi \
168+ browser/extensions/https-everywhere-eff@eff.org.xpi
169+ install -m 444 -D \
170+ ${firefoxExtensions.noscript} \
171+ browser/extensions/{73a6fe31-595d-460b-a920-fcc0f8843232}.xpi
172+
173+ # Copy bundle data
174+ cat \
175+ $TBBUILD/Bundle-Data/linux/Data/Tor/torrc-defaults \
176+ $TBBUILD/Bundle-Data/PTConfigs/linux/torrc-defaults-appendix \
177+ >> torrc-defaults
178+
179+ cat \
180+ $TBBUILD/Bundle-Data/linux/Data/Browser/profile.default/preferences/extension-overrides.js \
181+ $TBBUILD/Bundle-Data/PTConfigs/bridge_prefs.js >> defaults/pref/extension-overrides.js \
182+ >> defaults/pref/extension-overrides.js
183+
184+ # Generate a suitable wrapper
185+ mkdir -p $out/bin
186+ cat >$out/bin/tor-browser <<EOF
187+ #! ${stdenv.shell} -e
188+
189+ THE_HOME=\$HOME
190+ TBB_HOME=\''${TBB_HOME:-\''${XDG_DATA_HOME:-$HOME/.local/share}/tor-browser}
191+ mkdir -p "\$TBB_HOME"
192+
193+ HOME=\$TBB_HOME
194+ cd "\$HOME"
195+
196+ exec $self/firefox -no-remote about:tor
197+ EOF
198+ chmod +x $out/bin/tor-browser
199+ '';
200+
201+ meta = with stdenv.lib; {
202+ description = "An unofficial version of the tor browser bundle, built from source";
203+ homepage = https://torproject.org/;
204+ license = licenses.unfreeRedistributable; # TODO: check this
205+ platforms = [ "x86_64-linux" ];
206+ hydraPlatforms = [ ];
207+ maintainers = with maintainers; [ joachifm ];
208+ };
209+}
pkgs/top-level/all-packages.nix+5
@@ -4636,6 +4636,11 @@ with pkgs;
46364636
46374637 tor-browser-bundle-bin = callPackage ../applications/networking/browsers/tor-browser-bundle-bin { };
46384638
4639+ tor-browser-bundle = callPackage ../applications/networking/browsers/tor-browser-bundle {
4640+ stdenv = stdenvNoCC;
4641+ tor-browser-unwrapped = firefoxPackages.tor-browser;
4642+ };
4643+
46394644 touchegg = callPackage ../tools/inputmethods/touchegg { };
46404645
46414646 torsocks = callPackage ../tools/security/tor/torsocks.nix { };