2014-01-12 23:04:14 +01:00
|
|
|
{ stdenv, fetchurl, buildEnv
|
|
|
|
, xlibs, alsaLib, dbus, dbus_glib, glib, gtk, atk, pango, freetype, fontconfig
|
|
|
|
, gdk_pixbuf, cairo, zlib}:
|
|
|
|
let
|
|
|
|
bits = if stdenv.system == "x86_64-linux" then "64"
|
|
|
|
else "32";
|
|
|
|
|
|
|
|
# isolated tor environment
|
|
|
|
torEnv = buildEnv {
|
|
|
|
name = "tor-env";
|
|
|
|
paths = [
|
|
|
|
stdenv.gcc.gcc zlib glib alsaLib dbus dbus_glib gtk atk pango freetype
|
|
|
|
fontconfig gdk_pixbuf cairo xlibs.libXrender xlibs.libX11 xlibs.libXext
|
|
|
|
xlibs.libXt
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2014-03-01 22:37:39 +01:00
|
|
|
ldLibraryPath = if bits == "64" then torEnv+"/lib:"+torEnv+"/lib64"
|
|
|
|
else torEnv+"/lib";
|
|
|
|
|
2014-01-12 23:04:14 +01:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "tor-browser-${version}";
|
2014-05-07 15:24:20 +02:00
|
|
|
version = "3.6.1";
|
2014-01-12 23:04:14 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2014-05-07 15:24:20 +02:00
|
|
|
url = "https://archive.torproject.org/tor-package-archive/torbrowser/${version}/tor-browser-linux${bits}-${version}_en-US.tar.xz";
|
2014-01-12 23:04:14 +01:00
|
|
|
sha256 = if bits == "64" then
|
2014-05-07 15:24:20 +02:00
|
|
|
"1461l54zc7xgx2zcmi8wra38dknjyy8d2xk84chrwl6ckn2dfzv3" else
|
|
|
|
"183a1wf4a88sijfqr3m6gmvncq8w60i2rkymccg422n7q96j7hqs";
|
2014-01-12 23:04:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" Browser/firefox
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" Tor/tor
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
# Just do a simple test if all libraries get loaded by running help on
|
|
|
|
# firefox and tor
|
|
|
|
echo "Checking firefox..."
|
2014-03-01 22:37:39 +01:00
|
|
|
LD_LIBRARY_PATH=${ldLibraryPath} Browser/firefox --help 1> /dev/null
|
2014-01-12 23:04:14 +01:00
|
|
|
echo "Checking tor..."
|
|
|
|
LD_LIBRARY_PATH=${torEnv}/lib:Tor Tor/tor --help 1> /dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
ensureDir $out/share/tor-browser
|
|
|
|
ensureDir $out/bin
|
|
|
|
cp -R * $out/share/tor-browser
|
|
|
|
|
|
|
|
cat > "$out/bin/tor-browser" << EOF
|
|
|
|
export HOME="\$HOME/.torbrowser"
|
|
|
|
if [ ! -d \$HOME ]; then
|
|
|
|
mkdir -p \$HOME && cp -R $out/share/tor-browser/Data \$HOME/ && chmod -R +w \$HOME
|
|
|
|
echo "pref(\"extensions.torlauncher.tordatadir_path\", \"\$HOME/Data/Tor/\");" >> \
|
|
|
|
~/Data/Browser/profile.default/preferences/extension-overrides.js
|
|
|
|
fi
|
2014-03-01 22:37:39 +01:00
|
|
|
export LD_LIBRARY_PATH=${ldLibraryPath}:$out/share/tor-browser/Tor
|
2014-01-12 23:04:14 +01:00
|
|
|
$out/share/tor-browser/Browser/firefox -no-remote -profile ~/Data/Browser/profile.default "$@"
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/tor-browser
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ stdenv ];
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Tor Browser Bundle for GNU/Linux, everything you need to safely browse the Internet";
|
|
|
|
homepage = https://www.torproject.org/;
|
|
|
|
platforms = ["i686-linux" "x86_64-linux"];
|
2014-03-01 22:37:39 +01:00
|
|
|
maintainers = [ maintainers.offline maintainers.matejc ];
|
2014-01-12 23:04:14 +01:00
|
|
|
};
|
|
|
|
}
|