chromium: Use Nix expressions for plugin settings.

We now create Nix expressions within the plugin output path(s) which
then will be imported and incorporated into the wrapper. This makes it
easier for other plugins to provide configuration settings to the main
Chromium wrapper.

Of course, in order to allow for external plugins we need to allow
passing a list of plugins to the Chromium derivation, but right now we
keep it internal and only use it for things such as NaCl (as soon as we
support it, of course).

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-11-25 13:39:16 +01:00
parent 518173ac24
commit 690a845de9
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961
2 changed files with 26 additions and 14 deletions

View File

@ -69,14 +69,17 @@ in stdenv.mkDerivation {
buildCommand = let
browserBinary = "${chromium.browser}/libexec/chromium/chromium";
sandboxBinary = "${chromium.sandbox}/bin/chromium-sandbox";
in ''
mkEnvVar = key: val: "--set '${key}' '${val}'";
envVars = chromium.plugins.settings.envVars or {};
flags = chromium.plugins.settings.flags or [];
in with stdenv.lib; ''
mkdir -p "$out/bin" "$out/share/applications"
ln -s "${chromium.browser}/share" "$out/share"
makeWrapper "${browserBinary}" "$out/bin/chromium" \
--set CHROMIUM_SANDBOX_BINARY_PATH "${sandboxBinary}" \
--run "export ${chromium.plugins.envVarsEnabled}" \
--add-flags "${chromium.plugins.flagsEnabled}"
${concatStrings (mapAttrsToList mkEnvVar envVars)} \
--add-flags "${concatStringsSep " " flags}"
ln -s "$out/bin/chromium" "$out/bin/chromium-browser"
ln -s "${chromium.browser}/share/icons" "$out/share/icons"

View File

@ -62,29 +62,38 @@ let
install -vD PepperFlash/libpepflashplayer.so \
"$flash/lib/libpepflashplayer.so"
mkdir -p "$flash/nix-support"
echo "--ppapi-flash-path='$flash/lib/libpepflashplayer.so'" \
"--ppapi-flash-version=$flashVersion" \
> "$flash/nix-support/chromium-flags"
cat > "$flash/nix-support/chromium-plugin.nix" <<NIXOUT
{ flags = [
"--ppapi-flash-path='$flash/lib/libpepflashplayer.so'"
"--ppapi-flash-version=$flashVersion"
];
}
NIXOUT
install -vD libwidevinecdm.so \
"$widevine/lib/libwidevinecdm.so"
install -vD libwidevinecdmadapter.so \
"$widevine/lib/libwidevinecdmadapter.so"
mkdir -p "$widevine/nix-support"
echo "--register-pepper-plugins='${wvModule}${wvInfo}'" \
> "$widevine/nix-support/chromium-flags"
echo "NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE=$widevine/lib" \
> "$widevine/nix-support/chromium-env-vars"
cat > "$widevine/nix-support/chromium-plugin.nix" <<NIXOUT
{ flags = [ "--register-pepper-plugins='${wvModule}${wvInfo}'" ];
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
}
NIXOUT
'';
passthru = let
enabledPlugins = optional enablePepperFlash plugins.flash
++ optional enableWideVine plugins.widevine;
getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)";
getEnvVars = plugin: "$(< ${plugin}/nix-support/chromium-env-vars)";
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 ]) {};
in {
flagsEnabled = concatStringsSep " " (map getFlags enabledPlugins);
envVarsEnabled = concatStringsSep " " (map getEnvVars enabledPlugins);
settings = mergeAttrsets (map getNix enabledPlugins);
};
};
in plugins