tor-browser-bundle: minor refactorings
This commit is contained in:
parent
3ec05d6237
commit
387f1c75f5
@ -1,7 +1,6 @@
|
|||||||
{ stdenv
|
{ stdenv
|
||||||
, lib
|
|
||||||
, fetchurl
|
|
||||||
, fetchgit
|
, fetchgit
|
||||||
|
, fetchurl
|
||||||
, symlinkJoin
|
, symlinkJoin
|
||||||
|
|
||||||
, tor
|
, tor
|
||||||
@ -42,6 +41,8 @@
|
|||||||
, extraExtensions ? [ ]
|
, extraExtensions ? [ ]
|
||||||
}:
|
}:
|
||||||
|
|
||||||
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
tor-browser-build_src = fetchgit {
|
tor-browser-build_src = fetchgit {
|
||||||
url = "https://git.torproject.org/builders/tor-browser-build.git";
|
url = "https://git.torproject.org/builders/tor-browser-build.git";
|
||||||
@ -54,15 +55,12 @@ let
|
|||||||
git libxml2 python27 python27Packages rsync;
|
git libxml2 python27 python27Packages rsync;
|
||||||
};
|
};
|
||||||
|
|
||||||
extensionsEnv = symlinkJoin {
|
bundledExtensions = with firefoxExtensions; [
|
||||||
name = "tor-browser-extensions";
|
|
||||||
paths = with firefoxExtensions; [
|
|
||||||
https-everywhere
|
https-everywhere
|
||||||
noscript
|
noscript
|
||||||
torbutton
|
torbutton
|
||||||
tor-launcher
|
tor-launcher
|
||||||
] ++ extraExtensions;
|
] ++ extraExtensions;
|
||||||
};
|
|
||||||
|
|
||||||
fontsEnv = symlinkJoin {
|
fontsEnv = symlinkJoin {
|
||||||
name = "tor-browser-fonts";
|
name = "tor-browser-fonts";
|
||||||
@ -71,7 +69,7 @@ let
|
|||||||
|
|
||||||
fontsDir = "${fontsEnv}/share/fonts";
|
fontsDir = "${fontsEnv}/share/fonts";
|
||||||
|
|
||||||
gstPluginsPath = lib.concatMapStringsSep ":" (x:
|
gstPluginsPath = concatMapStringsSep ":" (x:
|
||||||
"${x}/lib/gstreamer-0.10") [
|
"${x}/lib/gstreamer-0.10") [
|
||||||
gstreamer
|
gstreamer
|
||||||
gst-plugins-base
|
gst-plugins-base
|
||||||
@ -79,7 +77,7 @@ let
|
|||||||
gst-ffmpeg
|
gst-ffmpeg
|
||||||
];
|
];
|
||||||
|
|
||||||
gstLibPath = lib.makeLibraryPath [
|
gstLibPath = makeLibraryPath [
|
||||||
gstreamer
|
gstreamer
|
||||||
gst-plugins-base
|
gst-plugins-base
|
||||||
gmp
|
gmp
|
||||||
@ -96,6 +94,11 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
buildPhase = ":";
|
buildPhase = ":";
|
||||||
|
|
||||||
|
# The following creates a customized firefox distribution. For
|
||||||
|
# simplicity, we copy the entire base firefox runtime, to work around
|
||||||
|
# firefox's annoying insistence on resolving the installation directory
|
||||||
|
# relative to the real firefox executable. A little tacky and
|
||||||
|
# inefficient but it works.
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
TBBUILD=${tor-browser-build_src}/projects/tor-browser
|
TBBUILD=${tor-browser-build_src}/projects/tor-browser
|
||||||
TBDATA_PATH=TorBrowser-Data
|
TBDATA_PATH=TorBrowser-Data
|
||||||
@ -123,6 +126,7 @@ stdenv.mkDerivation rec {
|
|||||||
lockPref("app.update.enabled", false);
|
lockPref("app.update.enabled", false);
|
||||||
lockPref("extensions.update.autoUpdateDefault", false);
|
lockPref("extensions.update.autoUpdateDefault", false);
|
||||||
lockPref("extensions.update.enabled", false);
|
lockPref("extensions.update.enabled", false);
|
||||||
|
lockPref("extensions.torbutton.updateNeeded", false);
|
||||||
lockPref("extensions.torbutton.versioncheck_enabled", false);
|
lockPref("extensions.torbutton.versioncheck_enabled", false);
|
||||||
|
|
||||||
// Where to find the Nixpkgs tor executable & config
|
// Where to find the Nixpkgs tor executable & config
|
||||||
@ -149,8 +153,7 @@ stdenv.mkDerivation rec {
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Preload extensions
|
# Preload extensions
|
||||||
# XXX: the fact that ln -s env browser/extensions fails, symlinkJoin seems a little redundant ...
|
find ${toString bundledExtensions} -name '*.xpi' -exec ln -s -t browser/extensions '{}' '+'
|
||||||
ln -s -t browser/extensions ${extensionsEnv}"/"*
|
|
||||||
|
|
||||||
# Copy bundle data
|
# Copy bundle data
|
||||||
bundlePlatform=linux
|
bundlePlatform=linux
|
||||||
@ -170,18 +173,18 @@ stdenv.mkDerivation rec {
|
|||||||
> $TBDATA_PATH/fonts.conf
|
> $TBDATA_PATH/fonts.conf
|
||||||
|
|
||||||
# Generate a suitable wrapper
|
# Generate a suitable wrapper
|
||||||
wrapper_PATH=${lib.makeBinPath [ coreutils ]}
|
wrapper_PATH=${makeBinPath [ coreutils ]}
|
||||||
wrapper_XDG_DATA_DIRS=${lib.concatMapStringsSep ":" (x: "${x}/share") [
|
wrapper_XDG_DATA_DIRS=${concatMapStringsSep ":" (x: "${x}/share") [
|
||||||
hicolor_icon_theme
|
hicolor_icon_theme
|
||||||
shared_mime_info
|
shared_mime_info
|
||||||
]}
|
]}
|
||||||
|
|
||||||
${lib.optionalString audioSupport ''
|
${optionalString audioSupport ''
|
||||||
# apulse uses a non-standard library path ...
|
# apulse uses a non-standard library path ...
|
||||||
wrapper_LD_LIBRARY_PATH=${apulse}/lib/apulse''${wrapper_LD_LIBRARY_PATH:+:$wrapper_LD_LIBRARY_PATH}
|
wrapper_LD_LIBRARY_PATH=${apulse}/lib/apulse''${wrapper_LD_LIBRARY_PATH:+:$wrapper_LD_LIBRARY_PATH}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
${lib.optionalString mediaSupport ''
|
${optionalString mediaSupport ''
|
||||||
wrapper_LD_LIBRARY_PATH=${gstLibPath}''${wrapper_LD_LIBRARY_PATH:+:$wrapper_LD_LIBRARY_PATH}
|
wrapper_LD_LIBRARY_PATH=${gstLibPath}''${wrapper_LD_LIBRARY_PATH:+:$wrapper_LD_LIBRARY_PATH}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
@ -189,10 +192,12 @@ stdenv.mkDerivation rec {
|
|||||||
cat >$out/bin/tor-browser <<EOF
|
cat >$out/bin/tor-browser <<EOF
|
||||||
#! ${stdenv.shell} -eu
|
#! ${stdenv.shell} -eu
|
||||||
|
|
||||||
|
umask 077
|
||||||
|
|
||||||
PATH=$wrapper_PATH
|
PATH=$wrapper_PATH
|
||||||
|
|
||||||
readonly THE_HOME=\$HOME
|
readonly THE_HOME=\$HOME
|
||||||
TBB_HOME=\''${TBB_HOME:-\''${XDG_DATA_HOME:-$HOME/.local/share}/tor-browser}
|
TBB_HOME=\''${TBB_HOME:-\''${XDG_DATA_HOME:-\$HOME/.local/share}/tor-browser}
|
||||||
if [[ \''${TBB_HOME:0:1} != / ]] ; then
|
if [[ \''${TBB_HOME:0:1} != / ]] ; then
|
||||||
TBB_HOME=\$PWD/\$TBB_HOME
|
TBB_HOME=\$PWD/\$TBB_HOME
|
||||||
fi
|
fi
|
||||||
@ -287,7 +292,7 @@ stdenv.mkDerivation rec {
|
|||||||
\
|
\
|
||||||
APULSE_PLAYBACK_DEVICE="\''${APULSE_PLAYBACK_DEVICE:-plug:dmix}" \
|
APULSE_PLAYBACK_DEVICE="\''${APULSE_PLAYBACK_DEVICE:-plug:dmix}" \
|
||||||
\
|
\
|
||||||
GST_PLUGIN_SYSTEM_PATH="${lib.optionalString mediaSupport gstPluginsPath}" \
|
GST_PLUGIN_SYSTEM_PATH="${optionalString mediaSupport gstPluginsPath}" \
|
||||||
GST_REGISTRY="/dev/null" \
|
GST_REGISTRY="/dev/null" \
|
||||||
GST_REGISTRY_UPDATE="no" \
|
GST_REGISTRY_UPDATE="no" \
|
||||||
\
|
\
|
||||||
@ -306,7 +311,7 @@ stdenv.mkDerivation rec {
|
|||||||
bash -n $out/bin/tor-browser
|
bash -n $out/bin/tor-browser
|
||||||
|
|
||||||
echo "Checking wrapper ..."
|
echo "Checking wrapper ..."
|
||||||
DISPLAY="" XAUTHORITY="" DBUS_SESSION_BUS_ADDRESS="" TBB_HOME=$TMPDIR/tbb \
|
DISPLAY="" XAUTHORITY="" DBUS_SESSION_BUS_ADDRESS="" TBB_HOME=$(mktemp -d) \
|
||||||
$out/bin/tor-browser -version >/dev/null
|
$out/bin/tor-browser -version >/dev/null
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
url = "https://git.torproject.org/https-everywhere.git";
|
url = "https://git.torproject.org/https-everywhere.git";
|
||||||
rev = "refs/tags/${version}";
|
rev = "refs/tags/${version}";
|
||||||
sha256 = "0z9madihh4b4z4blvfmh6w1hsv8afyi0x7b243nciq9r4w55xgfa";
|
sha256 = "0z9madihh4b4z4blvfmh6w1hsv8afyi0x7b243nciq9r4w55xgfa";
|
||||||
|
fetchSubmodules = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
@ -35,10 +36,6 @@
|
|||||||
zip
|
zip
|
||||||
];
|
];
|
||||||
|
|
||||||
unpackPhase = ''
|
|
||||||
cp -dR --no-preserve=mode "$src" src && cd src
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
$shell ./makexpi.sh ${version} --no-recurse
|
$shell ./makexpi.sh ${version} --no-recurse
|
||||||
'';
|
'';
|
||||||
@ -80,10 +77,6 @@
|
|||||||
|
|
||||||
nativeBuildInputs = [ zip ];
|
nativeBuildInputs = [ zip ];
|
||||||
|
|
||||||
unpackPhase = ''
|
|
||||||
cp -dR --no-preserve=mode "$src" src && cd src
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
$shell ./makexpi.sh
|
$shell ./makexpi.sh
|
||||||
'';
|
'';
|
||||||
@ -107,10 +100,6 @@
|
|||||||
|
|
||||||
nativeBuildInputs = [ zip ];
|
nativeBuildInputs = [ zip ];
|
||||||
|
|
||||||
unpackPhase = ''
|
|
||||||
cp -dR --no-preserve=mode "$src" src && cd src
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
make package
|
make package
|
||||||
'';
|
'';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user