git.iko.soy/typeable/nixpkgs
on master help sign in
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>

commit690a845de93a49e85480ad5fae492fa14658ce85 authoraszlig <aszlig@redmoonstudios.org> dateTue 25 Nov 2014, 13:39 (12 years ago) parent518173a
2 files changed+26−14
pkgs/applications/networking/browsers/chromium/default.nix+6−3 pkgs/applications/networking/browsers/chromium/plugins.nix+20−11
pkgs/applications/networking/browsers/chromium/default.nix+6−3
@@ -69,14 +69,17 @@ in stdenv.mkDerivation {
6969 buildCommand = let
7070 browserBinary = "${chromium.browser}/libexec/chromium/chromium";
7171 sandboxBinary = "${chromium.sandbox}/bin/chromium-sandbox";
72− in ''
72+ mkEnvVar = key: val: "--set '${key}' '${val}'";
73+ envVars = chromium.plugins.settings.envVars or {};
74+ flags = chromium.plugins.settings.flags or [];
75+ in with stdenv.lib; ''
7376 mkdir -p "$out/bin" "$out/share/applications"
7477
7578 ln -s "${chromium.browser}/share" "$out/share"
7679 makeWrapper "${browserBinary}" "$out/bin/chromium" \
7780 --set CHROMIUM_SANDBOX_BINARY_PATH "${sandboxBinary}" \
78− --run "export ${chromium.plugins.envVarsEnabled}" \
79− --add-flags "${chromium.plugins.flagsEnabled}"
81+ ${concatStrings (mapAttrsToList mkEnvVar envVars)} \
82+ --add-flags "${concatStringsSep " " flags}"
8083
8184 ln -s "$out/bin/chromium" "$out/bin/chromium-browser"
8285 ln -s "${chromium.browser}/share/icons" "$out/share/icons"
pkgs/applications/networking/browsers/chromium/plugins.nix+20−11
@@ -62,29 +62,38 @@ let
6262 install -vD PepperFlash/libpepflashplayer.so \
6363 "$flash/lib/libpepflashplayer.so"
6464 mkdir -p "$flash/nix-support"
65− echo "--ppapi-flash-path='$flash/lib/libpepflashplayer.so'" \
66− "--ppapi-flash-version=$flashVersion" \
67− > "$flash/nix-support/chromium-flags"
65+ cat > "$flash/nix-support/chromium-plugin.nix" <<NIXOUT
66+ { flags = [
67+ "--ppapi-flash-path='$flash/lib/libpepflashplayer.so'"
68+ "--ppapi-flash-version=$flashVersion"
69+ ];
70+ }
71+ NIXOUT
6872
6973 install -vD libwidevinecdm.so \
7074 "$widevine/lib/libwidevinecdm.so"
7175 install -vD libwidevinecdmadapter.so \
7276 "$widevine/lib/libwidevinecdmadapter.so"
7377 mkdir -p "$widevine/nix-support"
74− echo "--register-pepper-plugins='${wvModule}${wvInfo}'" \
75− > "$widevine/nix-support/chromium-flags"
76− echo "NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE=$widevine/lib" \
77− > "$widevine/nix-support/chromium-env-vars"
78+ cat > "$widevine/nix-support/chromium-plugin.nix" <<NIXOUT
79+ { flags = [ "--register-pepper-plugins='${wvModule}${wvInfo}'" ];
80+ envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
81+ }
82+ NIXOUT
7883 '';
7984
8085 passthru = let
8186 enabledPlugins = optional enablePepperFlash plugins.flash
8287 ++ optional enableWideVine plugins.widevine;
83− getFlags = plugin: "$(< ${plugin}/nix-support/chromium-flags)";
84− getEnvVars = plugin: "$(< ${plugin}/nix-support/chromium-env-vars)";
88+ getNix = plugin: import "${plugin}/nix-support/chromium-plugin.nix";
89+ mergeAttrsets = let
90+ f = v: if all isAttrs v then mergeAttrsets v
91+ else if all isList v then concatLists v
92+ else if tail v == [] then head v
93+ else head (tail v);
94+ in fold (l: r: zipAttrsWith (_: f) [ l r ]) {};
8595 in {
86− flagsEnabled = concatStringsSep " " (map getFlags enabledPlugins);
87− envVarsEnabled = concatStringsSep " " (map getEnvVars enabledPlugins);
96+ settings = mergeAttrsets (map getNix enabledPlugins);
8897 };
8998 };
9099in plugins