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
|
|
|
|
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}";
|
2015-01-23 00:48:56 +00:00
|
|
|
cext = if versionOlder source.version "41.0.0.0" then "lzma" else "xz";
|
2014-03-27 08:49:46 +00:00
|
|
|
in ''
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p plugins
|
2015-01-23 00:48:56 +00:00
|
|
|
ar p "$src" data.tar.${cext} | 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";
|
|
|
|
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"
|
2014-06-30 12:56:10 +00:00
|
|
|
mkdir -p "$flash/nix-support"
|
2014-11-25 12:39:16 +00:00
|
|
|
cat > "$flash/nix-support/chromium-plugin.nix" <<NIXOUT
|
|
|
|
{ flags = [
|
|
|
|
"--ppapi-flash-path='$flash/lib/libpepflashplayer.so'"
|
|
|
|
"--ppapi-flash-version=$flashVersion"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
NIXOUT
|
2014-09-30 04:00:47 +00:00
|
|
|
|
|
|
|
install -vD libwidevinecdm.so \
|
|
|
|
"$widevine/lib/libwidevinecdm.so"
|
|
|
|
install -vD libwidevinecdmadapter.so \
|
|
|
|
"$widevine/lib/libwidevinecdmadapter.so"
|
|
|
|
mkdir -p "$widevine/nix-support"
|
2014-11-25 12:39:16 +00:00
|
|
|
cat > "$widevine/nix-support/chromium-plugin.nix" <<NIXOUT
|
|
|
|
{ flags = [ "--register-pepper-plugins='${wvModule}${wvInfo}'" ];
|
|
|
|
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
|
|
|
|
}
|
|
|
|
NIXOUT
|
2014-03-19 11:57:49 +00:00
|
|
|
'';
|
|
|
|
|
2014-11-20 15:46:09 +00:00
|
|
|
passthru = let
|
2014-03-19 11:57:49 +00:00
|
|
|
enabledPlugins = optional enablePepperFlash plugins.flash
|
2014-09-30 04:00:47 +00:00
|
|
|
++ optional enableWideVine plugins.widevine;
|
2014-11-25 12:39:16 +00:00
|
|
|
getNix = plugin: import "${plugin}/nix-support/chromium-plugin.nix";
|
|
|
|
mergeAttrsets = let
|
|
|
|
f = v: if all isAttrs v then mergeAttrsets v
|
|
|
|
else if all isList v then concatLists v
|
|
|
|
else if tail v == [] then head v
|
|
|
|
else head (tail v);
|
|
|
|
in fold (l: r: zipAttrsWith (_: f) [ l r ]) {};
|
2014-11-20 15:46:09 +00:00
|
|
|
in {
|
2015-01-26 07:47:42 +00:00
|
|
|
inherit enabledPlugins;
|
2014-11-25 12:39:16 +00:00
|
|
|
settings = mergeAttrsets (map getNix enabledPlugins);
|
2014-11-20 15:46:09 +00:00
|
|
|
};
|
2014-03-19 11:57:49 +00:00
|
|
|
};
|
|
|
|
in plugins
|