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:
parent
518173ac24
commit
690a845de9
@ -69,14 +69,17 @@ in stdenv.mkDerivation {
|
|||||||
buildCommand = let
|
buildCommand = let
|
||||||
browserBinary = "${chromium.browser}/libexec/chromium/chromium";
|
browserBinary = "${chromium.browser}/libexec/chromium/chromium";
|
||||||
sandboxBinary = "${chromium.sandbox}/bin/chromium-sandbox";
|
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"
|
mkdir -p "$out/bin" "$out/share/applications"
|
||||||
|
|
||||||
ln -s "${chromium.browser}/share" "$out/share"
|
ln -s "${chromium.browser}/share" "$out/share"
|
||||||
makeWrapper "${browserBinary}" "$out/bin/chromium" \
|
makeWrapper "${browserBinary}" "$out/bin/chromium" \
|
||||||
--set CHROMIUM_SANDBOX_BINARY_PATH "${sandboxBinary}" \
|
--set CHROMIUM_SANDBOX_BINARY_PATH "${sandboxBinary}" \
|
||||||
--run "export ${chromium.plugins.envVarsEnabled}" \
|
${concatStrings (mapAttrsToList mkEnvVar envVars)} \
|
||||||
--add-flags "${chromium.plugins.flagsEnabled}"
|
--add-flags "${concatStringsSep " " flags}"
|
||||||
|
|
||||||
ln -s "$out/bin/chromium" "$out/bin/chromium-browser"
|
ln -s "$out/bin/chromium" "$out/bin/chromium-browser"
|
||||||
ln -s "${chromium.browser}/share/icons" "$out/share/icons"
|
ln -s "${chromium.browser}/share/icons" "$out/share/icons"
|
||||||
|
@ -62,29 +62,38 @@ let
|
|||||||
install -vD PepperFlash/libpepflashplayer.so \
|
install -vD PepperFlash/libpepflashplayer.so \
|
||||||
"$flash/lib/libpepflashplayer.so"
|
"$flash/lib/libpepflashplayer.so"
|
||||||
mkdir -p "$flash/nix-support"
|
mkdir -p "$flash/nix-support"
|
||||||
echo "--ppapi-flash-path='$flash/lib/libpepflashplayer.so'" \
|
cat > "$flash/nix-support/chromium-plugin.nix" <<NIXOUT
|
||||||
"--ppapi-flash-version=$flashVersion" \
|
{ flags = [
|
||||||
> "$flash/nix-support/chromium-flags"
|
"--ppapi-flash-path='$flash/lib/libpepflashplayer.so'"
|
||||||
|
"--ppapi-flash-version=$flashVersion"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
NIXOUT
|
||||||
|
|
||||||
install -vD libwidevinecdm.so \
|
install -vD libwidevinecdm.so \
|
||||||
"$widevine/lib/libwidevinecdm.so"
|
"$widevine/lib/libwidevinecdm.so"
|
||||||
install -vD libwidevinecdmadapter.so \
|
install -vD libwidevinecdmadapter.so \
|
||||||
"$widevine/lib/libwidevinecdmadapter.so"
|
"$widevine/lib/libwidevinecdmadapter.so"
|
||||||
mkdir -p "$widevine/nix-support"
|
mkdir -p "$widevine/nix-support"
|
||||||
echo "--register-pepper-plugins='${wvModule}${wvInfo}'" \
|
cat > "$widevine/nix-support/chromium-plugin.nix" <<NIXOUT
|
||||||
> "$widevine/nix-support/chromium-flags"
|
{ flags = [ "--register-pepper-plugins='${wvModule}${wvInfo}'" ];
|
||||||
echo "NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE=$widevine/lib" \
|
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
|
||||||
> "$widevine/nix-support/chromium-env-vars"
|
}
|
||||||
|
NIXOUT
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = let
|
passthru = let
|
||||||
enabledPlugins = optional enablePepperFlash plugins.flash
|
enabledPlugins = optional enablePepperFlash plugins.flash
|
||||||
++ optional enableWideVine plugins.widevine;
|
++ optional enableWideVine plugins.widevine;
|
||||||
getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)";
|
getNix = plugin: import "${plugin}/nix-support/chromium-plugin.nix";
|
||||||
getEnvVars = plugin: "$(< ${plugin}/nix-support/chromium-env-vars)";
|
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 {
|
in {
|
||||||
flagsEnabled = concatStringsSep " " (map getFlags enabledPlugins);
|
settings = mergeAttrsets (map getNix enabledPlugins);
|
||||||
envVarsEnabled = concatStringsSep " " (map getEnvVars enabledPlugins);
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in plugins
|
in plugins
|
||||||
|
Loading…
Reference in New Issue
Block a user