2018-10-24 20:56:13 +01:00
|
|
|
{ stdenv, gcc
|
2016-02-18 10:53:40 +00:00
|
|
|
, jshon
|
2017-09-21 09:00:37 +01:00
|
|
|
, glib
|
|
|
|
, nspr
|
|
|
|
, nss
|
2016-11-01 10:39:34 +00:00
|
|
|
, fetchzip
|
2017-09-21 09:00:37 +01:00
|
|
|
, patchelfUnstable
|
2016-11-01 10:39:34 +00:00
|
|
|
, enablePepperFlash ? false
|
2014-09-30 05:00:47 +01:00
|
|
|
, enableWideVine ? false
|
2014-03-27 08:49:46 +00:00
|
|
|
|
2016-03-20 16:50:17 +00:00
|
|
|
, upstream-info
|
2014-03-19 11:57:49 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
2016-11-01 10:39:34 +00:00
|
|
|
mkrpath = p: "${makeSearchPathOutput "lib" "lib64" p}:${makeLibraryPath p}";
|
|
|
|
|
2016-02-02 04:04:41 +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
|
2016-02-02 04:19:51 +00:00
|
|
|
shSearch = ["'"] ++ map (var: "@${var}@") allowedVars;
|
2016-02-02 04:04:41 +00:00
|
|
|
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"
|
|
|
|
'';
|
|
|
|
|
2016-10-29 02:29:42 +01:00
|
|
|
widevine = stdenv.mkDerivation {
|
|
|
|
name = "chromium-binary-plugin-widevine";
|
2014-03-19 11:57:49 +00:00
|
|
|
|
2016-03-20 16:50:17 +00:00
|
|
|
src = upstream-info.binary;
|
2014-03-19 11:57:49 +00:00
|
|
|
|
2017-09-21 09:00:37 +01:00
|
|
|
nativeBuildInputs = [ patchelfUnstable ];
|
|
|
|
|
2014-09-30 05:00:47 +01:00
|
|
|
phases = [ "unpackPhase" "patchPhase" "installPhase" "checkPhase" ];
|
2014-03-19 11:57:49 +00:00
|
|
|
|
2014-03-27 08:49:46 +00:00
|
|
|
unpackCmd = let
|
2016-03-20 16:50:17 +00:00
|
|
|
chan = if upstream-info.channel == "dev" then "chrome-unstable"
|
|
|
|
else if upstream-info.channel == "stable" then "chrome"
|
|
|
|
else "chrome-${upstream-info.channel}";
|
2014-03-27 08:49:46 +00:00
|
|
|
in ''
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p plugins
|
2015-06-19 18:35:30 +01:00
|
|
|
ar p "$src" data.tar.xz | tar xJ -C plugins --strip-components=4 \
|
2014-09-30 05:00:47 +01: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'
|
|
|
|
'';
|
|
|
|
|
2018-10-24 20:56:13 +01:00
|
|
|
PATCH_RPATH = mkrpath [ gcc.cc glib nspr nss ];
|
2014-09-30 05:00:47 +01:00
|
|
|
|
2018-01-22 00:19:56 +00:00
|
|
|
patchPhase = ''
|
|
|
|
chmod +x libwidevinecdm.so libwidevinecdmadapter.so
|
|
|
|
patchelf --set-rpath "$PATCH_RPATH" libwidevinecdm.so
|
|
|
|
patchelf --set-rpath "$out/lib:$PATCH_RPATH" libwidevinecdmadapter.so
|
2014-03-19 11:57:49 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = let
|
2014-09-30 05:00:47 +01:00
|
|
|
wvName = "Widevine Content Decryption Module";
|
|
|
|
wvDescription = "Playback of encrypted HTML audio/video content";
|
|
|
|
wvMimeTypes = "application/x-ppapi-widevine-cdm";
|
2016-10-29 02:29:42 +01:00
|
|
|
wvModule = "@out@/lib/libwidevinecdmadapter.so";
|
2015-08-04 04:37:35 +01:00
|
|
|
wvInfo = "#${wvName}#${wvDescription};${wvMimeTypes}";
|
2014-03-19 11:57:49 +00:00
|
|
|
in ''
|
2014-09-30 05:00:47 +01:00
|
|
|
install -vD libwidevinecdm.so \
|
2016-10-29 02:29:42 +01:00
|
|
|
"$out/lib/libwidevinecdm.so"
|
2014-09-30 05:00:47 +01:00
|
|
|
install -vD libwidevinecdmadapter.so \
|
2016-10-29 02:29:42 +01:00
|
|
|
"$out/lib/libwidevinecdmadapter.so"
|
2016-02-02 04:04:41 +00:00
|
|
|
|
|
|
|
${mkPluginInfo {
|
|
|
|
flags = [ "--register-pepper-plugins=${wvModule}${wvInfo}" ];
|
2016-10-29 02:29:42 +01:00
|
|
|
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "@out@/lib";
|
2016-02-02 04:04:41 +00:00
|
|
|
}}
|
2014-03-19 11:57:49 +00:00
|
|
|
'';
|
2018-10-16 17:11:41 +01:00
|
|
|
|
|
|
|
meta.platforms = platforms.x86_64;
|
2014-03-19 11:57:49 +00:00
|
|
|
};
|
2016-11-01 10:39:34 +00:00
|
|
|
|
|
|
|
flash = stdenv.mkDerivation rec {
|
|
|
|
name = "flashplayer-ppapi-${version}";
|
2019-06-11 07:13:34 +01:00
|
|
|
version = "32.0.0.207";
|
2016-11-01 10:39:34 +00:00
|
|
|
|
|
|
|
src = fetchzip {
|
2018-07-12 00:34:16 +01:00
|
|
|
url = "https://fpdownload.adobe.com/pub/flashplayer/pdc/${version}/flash_player_ppapi_linux.x86_64.tar.gz";
|
2019-06-11 07:13:34 +01:00
|
|
|
sha256 = "09bbrlnw343ygcibyjfa27r8gjdg1dcxx85d3v4v93wfi29nl789";
|
2016-11-01 10:39:34 +00:00
|
|
|
stripRoot = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
chmod +x libpepflashplayer.so
|
2018-10-24 20:56:13 +01:00
|
|
|
patchelf --set-rpath "${mkrpath [ gcc.cc ]}" libpepflashplayer.so
|
2016-11-01 10:39:34 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
! find -iname '*.so' -exec ldd {} + | grep 'not found'
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
flashVersion="$(
|
|
|
|
"${jshon}/bin/jshon" -F manifest.json -e version -u
|
|
|
|
)"
|
|
|
|
|
|
|
|
install -vD libpepflashplayer.so "$out/lib/libpepflashplayer.so"
|
|
|
|
|
|
|
|
${mkPluginInfo {
|
|
|
|
allowedVars = [ "out" "flashVersion" ];
|
|
|
|
flags = [
|
|
|
|
"--ppapi-flash-path=@out@/lib/libpepflashplayer.so"
|
|
|
|
"--ppapi-flash-version=@flashVersion@"
|
|
|
|
];
|
|
|
|
}}
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
2018-10-16 17:11:41 +01:00
|
|
|
|
|
|
|
meta.platforms = platforms.x86_64;
|
2016-11-01 10:39:34 +00:00
|
|
|
};
|
|
|
|
|
2016-10-29 02:29:42 +01:00
|
|
|
in {
|
2016-11-01 10:39:34 +00:00
|
|
|
enabled = optional enableWideVine widevine
|
|
|
|
++ optional enablePepperFlash flash;
|
2016-10-29 02:29:42 +01:00
|
|
|
}
|