chromium: Remove import-from-derivation again
This reverts commitf7af2272a2
. We're going to fix #12710 properly by reintroducing38c77bb
and fixing the shell variable substitution. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
52475afe77
commit
ff90f52375
@ -64,20 +64,17 @@ let
|
|||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
name = "chromium${suffix}-${chromium.browser.version}";
|
name = "chromium${suffix}-${chromium.browser.version}";
|
||||||
|
|
||||||
buildInputs = [ makeWrapper ] ++ chromium.plugins.enabledPlugins;
|
buildInputs = [ makeWrapper ];
|
||||||
|
|
||||||
buildCommand = let
|
buildCommand = let
|
||||||
browserBinary = "${chromium.browser}/libexec/chromium/chromium";
|
browserBinary = "${chromium.browser}/libexec/chromium/chromium";
|
||||||
mkEnvVar = key: val: "--set '${key}' '${val}'";
|
getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")";
|
||||||
envVars = chromium.plugins.settings.envVars or {};
|
|
||||||
flags = chromium.plugins.settings.flags or [];
|
|
||||||
in with stdenv.lib; ''
|
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" \
|
eval makeWrapper "${browserBinary}" "$out/bin/chromium" \
|
||||||
${concatStrings (mapAttrsToList mkEnvVar envVars)} \
|
${concatMapStringsSep " " getWrapperFlags chromium.plugins.enabled}
|
||||||
--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"
|
||||||
|
@ -8,6 +8,34 @@
|
|||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
# Generate a shell fragment that emits flags appended to the
|
||||||
|
# final makeWrapper call for wrapping the browser's main binary.
|
||||||
|
#
|
||||||
|
# Note that this is shell-escaped so that only the variable specified
|
||||||
|
# by the "output" attribute is substituted.
|
||||||
|
mkPluginInfo = { output ? "out", allowedVars ? [ output ]
|
||||||
|
, flags ? [], envVars ? {}
|
||||||
|
}: let
|
||||||
|
shSearch = ["'"] ++ map (var: "\$${var}") allowedVars;
|
||||||
|
shReplace = ["'\\''"] ++ map (var: "'\"\${${var}}\"'") allowedVars;
|
||||||
|
# We need to triple-escape "val":
|
||||||
|
# * First because makeWrapper doesn't do any quoting of its arguments by
|
||||||
|
# itself.
|
||||||
|
# * Second because it's passed to the makeWrapper call separated by IFS but
|
||||||
|
# not by the _real_ arguments, for example the Widevine plugin flags
|
||||||
|
# contain spaces, so they would end up as separate arguments.
|
||||||
|
# * Third in order to be correctly quoted for the "echo" call below.
|
||||||
|
shEsc = val: "'${replaceStrings ["'"] ["'\\''"] val}'";
|
||||||
|
mkSh = val: "'${replaceStrings shSearch shReplace (shEsc val)}'";
|
||||||
|
mkFlag = flag: ["--add-flags" (shEsc flag)];
|
||||||
|
mkEnvVar = key: val: ["--set" (shEsc key) (shEsc val)];
|
||||||
|
envList = mapAttrsToList mkEnvVar envVars;
|
||||||
|
quoted = map mkSh (flatten ((map mkFlag flags) ++ envList));
|
||||||
|
in ''
|
||||||
|
mkdir -p "''$${output}/nix-support"
|
||||||
|
echo ${toString quoted} > "''$${output}/nix-support/wrapper-flags"
|
||||||
|
'';
|
||||||
|
|
||||||
plugins = stdenv.mkDerivation {
|
plugins = stdenv.mkDerivation {
|
||||||
name = "chromium-binary-plugins";
|
name = "chromium-binary-plugins";
|
||||||
|
|
||||||
@ -61,40 +89,29 @@ let
|
|||||||
|
|
||||||
install -vD PepperFlash/libpepflashplayer.so \
|
install -vD PepperFlash/libpepflashplayer.so \
|
||||||
"$flash/lib/libpepflashplayer.so"
|
"$flash/lib/libpepflashplayer.so"
|
||||||
mkdir -p "$flash/nix-support"
|
|
||||||
cat > "$flash/nix-support/chromium-plugin.nix" <<NIXOUT
|
${mkPluginInfo {
|
||||||
{ flags = [
|
output = "flash";
|
||||||
"--ppapi-flash-path='$flash/lib/libpepflashplayer.so'"
|
allowedVars = [ "flash" "flashVersion" ];
|
||||||
"--ppapi-flash-version=$flashVersion"
|
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"
|
|
||||||
cat > "$widevine/nix-support/chromium-plugin.nix" <<NIXOUT
|
${mkPluginInfo {
|
||||||
{ flags = [ "--register-pepper-plugins='${wvModule}${wvInfo}'" ];
|
output = "widevine";
|
||||||
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
|
flags = [ "--register-pepper-plugins=${wvModule}${wvInfo}" ];
|
||||||
}
|
envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
|
||||||
NIXOUT
|
}}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = let
|
passthru.enabled = optional enablePepperFlash plugins.flash
|
||||||
enabledPlugins = optional enablePepperFlash plugins.flash
|
|
||||||
++ optional enableWideVine plugins.widevine;
|
++ optional enableWideVine plugins.widevine;
|
||||||
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 {
|
|
||||||
inherit enabledPlugins;
|
|
||||||
settings = mergeAttrsets (map getNix enabledPlugins);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
in plugins
|
in plugins
|
||||||
|
Loading…
Reference in New Issue
Block a user