nixpkgs/pkgs/tools/security/tor/torbrowser.nix

88 lines
3.0 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, buildEnv, makeDesktopItem
, xorg, alsaLib, dbus, dbus_glib, glib, gtk, atk, pango, freetype, fontconfig
2014-01-12 22:04:14 +00:00
, gdk_pixbuf, cairo, zlib}:
let
# isolated tor environment
torEnv = buildEnv {
name = "tor-env";
paths = [
stdenv.cc.cc zlib glib alsaLib dbus dbus_glib gtk atk pango freetype
fontconfig gdk_pixbuf cairo xorg.libXrender xorg.libX11 xorg.libXext
xorg.libXt
2014-01-12 22:04:14 +00:00
];
extraOutputsToInstall = [ "lib" "out" ];
2014-01-12 22:04:14 +00:00
};
2015-06-19 12:04:18 +01:00
ldLibraryPath = ''${torEnv}/lib${stdenv.lib.optionalString stdenv.is64bit ":${torEnv}/lib64"}'';
2014-01-12 22:04:14 +00:00
in stdenv.mkDerivation rec {
name = "tor-browser-${version}";
2016-04-28 17:15:36 +01:00
version = "5.5.5";
2014-01-12 22:04:14 +00:00
src = fetchurl {
2015-06-19 12:04:18 +01:00
url = "https://archive.torproject.org/tor-package-archive/torbrowser/${version}/tor-browser-linux${if stdenv.is64bit then "64" else "32"}-${version}_en-US.tar.xz";
sha256 = if stdenv.is64bit then
2016-04-28 17:15:36 +01:00
"0k6v41j880fb4zdxk1v13kmizdaz5rwvi5lskdbdi68iml4p53gj" else
"04mqjmnxwa75yi8gmdwadkzrzikgxn08bkvr50zdm7id9fj4nkza";
};
desktopItem = makeDesktopItem {
name = "torbrowser";
exec = "tor-browser";
icon = "torbrowser";
desktopName = "Tor Browser";
genericName = "Tor Browser";
comment = meta.description;
categories = "Network;WebBrowser;Security;";
2014-01-12 22:04:14 +00:00
};
patchPhase = ''
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..."
LD_LIBRARY_PATH=${ldLibraryPath} Browser/firefox --help 1> /dev/null
2014-01-12 22:04:14 +00:00
echo "Checking tor..."
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 = ''
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
#!${stdenv.shell}
export HOME="\$HOME/.torbrowser4"
if [ ! -d \$HOME ]; then
mkdir -p \$HOME && cp -R $out/share/tor-browser/Browser/TorBrowser/Data \$HOME/ && chmod -R +w \$HOME
echo "pref(\"extensions.torlauncher.tordatadir_path\", \"\$HOME/Data/Tor/\");" >> \
~/Data/Browser/profile.default/preferences/extension-overrides.js
fi
export LD_LIBRARY_PATH=${ldLibraryPath}:$out/share/tor-browser/Browser/TorBrowser/Tor
$out/share/tor-browser/Browser/firefox -no-remote -profile ~/Data/Browser/profile.default "\$@"
2014-01-12 22:04:14 +00:00
EOF
chmod +x $out/bin/tor-browser
mkdir -p $out/share/applications
cp $desktopItem/share/applications"/"* $out/share/applications
mkdir -p $out/share/pixmaps
cp Browser/browser/icons/mozicon128.png $out/share/pixmaps/torbrowser.png
2014-01-12 22:04:14 +00:00
'';
buildInputs = [ stdenv ];
meta = with stdenv.lib; {
description = "Tor Browser Bundle";
homepage = https://www.torproject.org/;
platforms = platforms.linux;
maintainers = with maintainers; [ offline matejc doublec thoughtpolice ];
2014-01-12 22:04:14 +00:00
};
}