2014-03-19 11:57:49 +00:00
|
|
|
{ stdenv
|
|
|
|
, enablePepperFlash ? false
|
2014-09-30 04:00:47 +00:00
|
|
|
, enableWideVine ? false
|
2014-03-27 08:49:46 +00:00
|
|
|
|
|
|
|
, source
|
2014-03-19 11:57:49 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
2016-01-18 02:21:15 +00:00
|
|
|
# Generate a shell fragment that emits flags appended to the
|
|
|
|
# final makeWrapper call for wrapping the browser's main binary.
|
|
|
|
#
|
|
|
|
# Note that this is shell-escaped so that only the variable specified
|
|
|
|
# by the "output" attribute is substituted.
|
|
|
|
mkPluginInfo = { output ? "out", allowedVars ? [ output ]
|
|
|
|
, flags ? [], envVars ? {}
|
|
|
|
}: let
|
|
|
|
shSearch = ["'"] ++ map (var: "\$${var}") allowedVars;
|
|
|
|
shReplace = ["'\\''"] ++ map (var: "'\"\${${var}}\"'") allowedVars;
|
|
|
|
# We need to triple-escape "val":
|
|
|
|
# * First because makeWrapper doesn't do any quoting of its arguments by
|
|
|
|
# itself.
|
|
|
|
# * Second because it's passed to the makeWrapper call separated by IFS but
|
|
|
|
# not by the _real_ arguments, for example the Widevine plugin flags
|
|
|
|
# contain spaces, so they would end up as separate arguments.
|
|
|
|
# * Third in order to be correctly quoted for the "echo" call below.
|
|
|
|
shEsc = val: "'${replaceStrings ["'"] ["'\\''"] val}'";
|
|
|
|
mkSh = val: "'${replaceStrings shSearch shReplace (shEsc val)}'";
|
|
|
|
mkFlag = flag: ["--add-flags" (shEsc flag)];
|
|
|
|
mkEnvVar = key: val: ["--set" (shEsc key) (shEsc val)];
|
|
|
|
envList = mapAttrsToList mkEnvVar envVars;
|
|
|
|
quoted = map mkSh (flatten ((map mkFlag flags) ++ envList));
|
|
|
|
in ''
|
|
|
|
mkdir -p "''$${output}/nix-support"
|
|
|
|
echo ${toString quoted} > "''$${output}/nix-support/wrapper-flags"
|
|
|
|
'';
|
|
|
|
|
2014-03-19 11:57:49 +00:00
|
|
|
plugins = stdenv.mkDerivation {
|
|
|
|
name = "chromium-binary-plugins";
|
|
|
|
|
|
|
|
# XXX: Only temporary and has to be version-specific
|
2014-03-27 08:49:46 +00:00
|
|
|
src = source.plugins;
|
2014-03-19 11:57:49 +00:00
|
|
|
|
2014-09-30 04:00:47 +00:00
|
|
|
phases = [ "unpackPhase" "patchPhase" "installPhase" "checkPhase" ];
|
2014-11-21 15:34:05 +00:00
|
|
|
outputs = [ "flash" "widevine" ];
|
2014-03-19 11:57:49 +00:00
|
|
|
|
2014-03-27 08:49:46 +00:00
|
|
|
unpackCmd = let
|
|
|
|
chan = if source.channel == "dev" then "chrome-unstable"
|
|
|
|
else if source.channel == "stable" then "chrome"
|
|
|
|
else "chrome-${source.channel}";
|
|
|
|
in ''
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p plugins
|
2015-06-19 17:35:30 +00:00
|
|
|
ar p "$src" data.tar.xz | tar xJ -C plugins --strip-components=4 \
|
2014-03-27 08:49:46 +00:00
|
|
|
./opt/google/${chan}/PepperFlash \
|
2014-09-30 04:00:47 +00:00
|
|
|
./opt/google/${chan}/libwidevinecdm.so \
|
|
|
|
./opt/google/${chan}/libwidevinecdmadapter.so
|
2014-03-19 11:57:49 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
! find -iname '*.so' -exec ldd {} + | grep 'not found'
|
|
|
|
'';
|
|
|
|
|
|
|
|
patchPhase = let
|
2015-01-15 04:25:26 +00:00
|
|
|
rpaths = [ stdenv.cc.cc ];
|
2014-03-19 11:57:49 +00:00
|
|
|
mkrpath = p: "${makeSearchPath "lib64" p}:${makeSearchPath "lib" p}";
|
|
|
|
in ''
|
2014-11-21 15:34:05 +00:00
|
|
|
for sofile in PepperFlash/libpepflashplayer.so \
|
2014-09-30 04:00:47 +00:00
|
|
|
libwidevinecdm.so libwidevinecdmadapter.so; do
|
2014-03-19 11:57:49 +00:00
|
|
|
chmod +x "$sofile"
|
|
|
|
patchelf --set-rpath "${mkrpath rpaths}" "$sofile"
|
|
|
|
done
|
2014-09-30 04:00:47 +00:00
|
|
|
|
|
|
|
patchelf --set-rpath "$widevine/lib:${mkrpath rpaths}" \
|
|
|
|
libwidevinecdmadapter.so
|
2014-03-19 11:57:49 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = let
|
2014-09-30 04:00:47 +00:00
|
|
|
wvName = "Widevine Content Decryption Module";
|
|
|
|
wvDescription = "Playback of encrypted HTML audio/video content";
|
|
|
|
wvMimeTypes = "application/x-ppapi-widevine-cdm";
|
|
|
|
wvModule = "$widevine/lib/libwidevinecdmadapter.so";
|
2015-08-04 03:37:35 +00:00
|
|
|
wvInfo = "#${wvName}#${wvDescription};${wvMimeTypes}";
|
2014-03-19 11:57:49 +00:00
|
|
|
in ''
|
|
|
|
flashVersion="$(
|
|
|
|
sed -n -r 's/.*"version": "([^"]+)",.*/\1/p' PepperFlash/manifest.json
|
|
|
|
)"
|
|
|
|
|
|
|
|
install -vD PepperFlash/libpepflashplayer.so \
|
|
|
|
"$flash/lib/libpepflashplayer.so"
|
2016-01-18 02:21:15 +00:00
|
|
|
|
|
|
|
${mkPluginInfo {
|
|
|
|
output = "flash";
|
|
|
|
allowedVars = [ "flash" "flashVersion" ];
|
|
|
|
flags = [
|
|
|
|
"--ppapi-flash-path=$flash/lib/libpepflashplayer.so"
|
|
|
|
"--ppapi-flash-version=$flashVersion"
|
|
|
|
];
|
|
|
|
}}
|
2014-09-30 04:00:47 +00:00
|
|
|
|
|
|
|
install -vD libwidevinecdm.so \
|
|
|
|
"$widevine/lib/libwidevinecdm.so"
|
|
|
|
install -vD libwidevinecdmadapter.so \
|
|
|
|
"$widevine/lib/libwidevinecdmadapter.so"
|
2016-01-18 02:21:15 +00:00
|
|
|
|
|
|
|
${mkPluginInfo {
|
|
|
|
output = "widevine";
|
|
|
|
flags = [ "--register-pepper-plugins=${wvModule}${wvInfo}" ];
|
|
|
|
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
|
|
|
|
}}
|
2014-03-19 11:57:49 +00:00
|
|
|
'';
|
|
|
|
|
2016-01-18 02:21:15 +00:00
|
|
|
passthru.enabled = optional enablePepperFlash plugins.flash
|
2014-09-30 04:00:47 +00:00
|
|
|
++ optional enableWideVine plugins.widevine;
|
2014-03-19 11:57:49 +00:00
|
|
|
};
|
|
|
|
in plugins
|