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

12 comments on commit 690a845

@vcunat
Copy link
Member

@vcunat vcunat commented on 690a845 Nov 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly!! It causes building plugins even during instantiation (e.g. --dry-run). Fix it, please.

@aszlig
Copy link
Member Author

@aszlig aszlig commented on 690a845 Nov 5, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do it right now, sorry... have to crunch on #2079 for NixCon. Going to fix it afterwards (plus a few more issues on Chromium).

@vcunat
Copy link
Member

@vcunat vcunat commented on 690a845 Jan 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping!

@vcunat
Copy link
Member

@vcunat vcunat commented on 690a845 Jan 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: both master and 15.09 are affected.

@aszlig
Copy link
Member Author

@aszlig aszlig commented on 690a845 Jan 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vcunat: Sorry for keeping you waiting, fixing ASAP.

@aszlig
Copy link
Member Author

@aszlig aszlig commented on 690a845 Jan 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 38c77bb but I'd give it some time for testing in master until cherry-picking it to 15.09, because I have not tested the flag combinations thoroughly.

@vcunat
Copy link
Member

@vcunat vcunat commented on 690a845 Jan 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, sounds fine. I agree to wait a bit.

@vcunat
Copy link
Member

@vcunat vcunat commented on 690a845 Jan 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problems encountered yet?

@aszlig
Copy link
Member Author

@aszlig aszlig commented on 690a845 Jan 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None that I know of yet, so I'm going to cherry-pick to stable then...

@aszlig
Copy link
Member Author

@aszlig aszlig commented on 690a845 Jan 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cherry-picked in 2fd9d7b.

@vcunat
Copy link
Member

@vcunat vcunat commented on 690a845 Jan 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-)

@vcunat
Copy link
Member

@vcunat vcunat commented on 690a845 Jan 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This brings problems #12710.

Please sign in to comment.