2014-01-12 22:04:14 +00:00
|
|
|
{ stdenv, fetchurl, buildEnv
|
2015-09-15 10:26:18 +01:00
|
|
|
, xorg, alsaLib, dbus, dbus_glib, glib, gtk, atk, pango, freetype, fontconfig
|
2014-01-12 22:04:14 +00:00
|
|
|
, 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 = [
|
2015-01-15 04:25:26 +00:00
|
|
|
stdenv.cc.cc zlib glib alsaLib dbus dbus_glib gtk atk pango freetype
|
2015-09-15 10:26:18 +01:00
|
|
|
fontconfig gdk_pixbuf cairo xorg.libXrender xorg.libX11 xorg.libXext
|
|
|
|
xorg.libXt
|
2014-01-12 22:04:14 +00:00
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2014-03-01 21:37:39 +00:00
|
|
|
ldLibraryPath = if bits == "64" then torEnv+"/lib:"+torEnv+"/lib64"
|
|
|
|
else torEnv+"/lib";
|
|
|
|
|
2014-01-12 22:04:14 +00:00
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "tor-browser-${version}";
|
2015-07-22 20:15:25 +01:00
|
|
|
version = "4.5.3";
|
2014-01-12 22:04:14 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2014-05-07 14:24:20 +01:00
|
|
|
url = "https://archive.torproject.org/tor-package-archive/torbrowser/${version}/tor-browser-linux${bits}-${version}_en-US.tar.xz";
|
2014-01-12 22:04:14 +00:00
|
|
|
sha256 = if bits == "64" then
|
2015-07-22 20:15:25 +01:00
|
|
|
"24c517d2aeb15ba5eeda1eb87f483ed4fb0c22b07a95ca26af9f692e0d4d9b7c" else
|
|
|
|
"154d659583048e91870c40921561f0519babf6d3c9ac439f6fb74ed66824463f";
|
2014-01-12 22:04:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''
|
2014-12-17 18:11:30 +00:00
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" Browser/firefox
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" Browser/TorBrowser/Tor/tor
|
2014-01-12 22:04:14 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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 21:37:39 +00:00
|
|
|
LD_LIBRARY_PATH=${ldLibraryPath} Browser/firefox --help 1> /dev/null
|
2014-01-12 22:04:14 +00:00
|
|
|
echo "Checking tor..."
|
2014-11-17 20:52:29 +00:00
|
|
|
LD_LIBRARY_PATH=${torEnv}/lib:Browser/TorBrowser/Tor Browser/TorBrowser/Tor/tor --help 1> /dev/null
|
2014-01-12 22:04:14 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/share/tor-browser
|
|
|
|
mkdir -p $out/bin
|
2014-01-12 22:04:14 +00:00
|
|
|
cp -R * $out/share/tor-browser
|
|
|
|
|
|
|
|
cat > "$out/bin/tor-browser" << EOF
|
2014-11-17 20:52:29 +00:00
|
|
|
export HOME="\$HOME/.torbrowser4"
|
2014-01-12 22:04:14 +00:00
|
|
|
if [ ! -d \$HOME ]; then
|
2014-11-17 20:52:29 +00:00
|
|
|
mkdir -p \$HOME && cp -R $out/share/tor-browser/Browser/TorBrowser/Data \$HOME/ && chmod -R +w \$HOME
|
2014-01-12 22:04:14 +00:00
|
|
|
echo "pref(\"extensions.torlauncher.tordatadir_path\", \"\$HOME/Data/Tor/\");" >> \
|
|
|
|
~/Data/Browser/profile.default/preferences/extension-overrides.js
|
|
|
|
fi
|
2014-11-17 20:52:29 +00:00
|
|
|
export LD_LIBRARY_PATH=${ldLibraryPath}:$out/share/tor-browser/Browser/TorBrowser/Tor
|
2014-01-12 22:04:14 +00:00
|
|
|
$out/share/tor-browser/Browser/firefox -no-remote -profile ~/Data/Browser/profile.default "$@"
|
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/tor-browser
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ stdenv ];
|
|
|
|
|
2014-12-06 10:43:06 +00:00
|
|
|
meta = {
|
|
|
|
description = "Tor Browser Bundle";
|
|
|
|
homepage = https://www.torproject.org/;
|
|
|
|
platforms = stdenv.lib.platforms.linux;
|
|
|
|
maintainers = with stdenv.lib.maintainers;
|
|
|
|
[ offline matejc doublec thoughtpolice ];
|
2014-01-12 22:04:14 +00:00
|
|
|
};
|
|
|
|
}
|