61042a5b6a
There is already a pull request from @colemickens, who has just reversed the variable references $flash and $flashVersion but the fix is kinda fragile as he points out himself in #12713. The reason the wrong substition was made is that both variables begin with the same name and we do a simple replace instead of a more complicated one using builtins.match. So staying simple but to still not raising issues with other variables that begin with the same name I'm now using @var@ instead, like we use in substituteAll and other substituters (like the ones in CMake or autotools) deal with it. Note that I'm not using $var$ here to make sure it doesn't get confused with real shell variables. So with this fix in place, the wrapper now has the following flags: --ppapi-flash-path=/nix/store/.../lib/libpepflashplayer.so --ppapi-flash-version=20.0.0.294 Previously we had (#12710): --ppapi-flash-path=/nix/store/.../lib/libpepflashplayer.so --ppapi-flash-version=/nix/store/...-binary-plugins-flashVersion Thanks to @colemickens for reporting and putting up a pull request. Signed-off-by: aszlig <aszlig@redmoonstudios.org> Fixes: #12710 Fixes: #12713
118 lines
4.0 KiB
Nix
118 lines
4.0 KiB
Nix
{ stdenv
|
|
, enablePepperFlash ? false
|
|
, enableWideVine ? false
|
|
|
|
, source
|
|
}:
|
|
|
|
with stdenv.lib;
|
|
|
|
let
|
|
# 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"
|
|
'';
|
|
|
|
plugins = stdenv.mkDerivation {
|
|
name = "chromium-binary-plugins";
|
|
|
|
# XXX: Only temporary and has to be version-specific
|
|
src = source.plugins;
|
|
|
|
phases = [ "unpackPhase" "patchPhase" "installPhase" "checkPhase" ];
|
|
outputs = [ "flash" "widevine" ];
|
|
|
|
unpackCmd = let
|
|
chan = if source.channel == "dev" then "chrome-unstable"
|
|
else if source.channel == "stable" then "chrome"
|
|
else "chrome-${source.channel}";
|
|
in ''
|
|
mkdir -p plugins
|
|
ar p "$src" data.tar.xz | tar xJ -C plugins --strip-components=4 \
|
|
./opt/google/${chan}/PepperFlash \
|
|
./opt/google/${chan}/libwidevinecdm.so \
|
|
./opt/google/${chan}/libwidevinecdmadapter.so
|
|
'';
|
|
|
|
doCheck = true;
|
|
checkPhase = ''
|
|
! find -iname '*.so' -exec ldd {} + | grep 'not found'
|
|
'';
|
|
|
|
patchPhase = let
|
|
rpaths = [ stdenv.cc.cc ];
|
|
mkrpath = p: "${makeSearchPath "lib64" p}:${makeSearchPath "lib" p}";
|
|
in ''
|
|
for sofile in PepperFlash/libpepflashplayer.so \
|
|
libwidevinecdm.so libwidevinecdmadapter.so; do
|
|
chmod +x "$sofile"
|
|
patchelf --set-rpath "${mkrpath rpaths}" "$sofile"
|
|
done
|
|
|
|
patchelf --set-rpath "$widevine/lib:${mkrpath rpaths}" \
|
|
libwidevinecdmadapter.so
|
|
'';
|
|
|
|
installPhase = let
|
|
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}";
|
|
in ''
|
|
flashVersion="$(
|
|
sed -n -r 's/.*"version": "([^"]+)",.*/\1/p' PepperFlash/manifest.json
|
|
)"
|
|
|
|
install -vD PepperFlash/libpepflashplayer.so \
|
|
"$flash/lib/libpepflashplayer.so"
|
|
|
|
${mkPluginInfo {
|
|
output = "flash";
|
|
allowedVars = [ "flash" "flashVersion" ];
|
|
flags = [
|
|
"--ppapi-flash-path=@flash@/lib/libpepflashplayer.so"
|
|
"--ppapi-flash-version=@flashVersion@"
|
|
];
|
|
}}
|
|
|
|
install -vD libwidevinecdm.so \
|
|
"$widevine/lib/libwidevinecdm.so"
|
|
install -vD libwidevinecdmadapter.so \
|
|
"$widevine/lib/libwidevinecdmadapter.so"
|
|
|
|
${mkPluginInfo {
|
|
output = "widevine";
|
|
flags = [ "--register-pepper-plugins=${wvModule}${wvInfo}" ];
|
|
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "@widevine@/lib";
|
|
}}
|
|
'';
|
|
|
|
passthru.enabled = optional enablePepperFlash plugins.flash
|
|
++ optional enableWideVine plugins.widevine;
|
|
};
|
|
in plugins
|