Skip to content

Commit

Permalink
chromium: Use Nix expressions for plugin settings.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aszlig committed Nov 25, 2014
1 parent 518173a commit 690a845
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
9 changes: 6 additions & 3 deletions pkgs/applications/networking/browsers/chromium/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
31 changes: 20 additions & 11 deletions pkgs/applications/networking/browsers/chromium/plugins.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 690a845

Please sign in to comment.