git.iko.soy/typeable/nixpkgs
on master help sign in
chromium: Remove import-from-derivation again

This reverts commit f7af2272a2ea8f12eecd337aee046345172bebec. We're going to fix #12710 properly by reintroducing 38c77bb and fixing the shell variable substitution. Signed-off-by: aszlig <aszlig@redmoonstudios.org>

commitff90f52375ef9c2ffb1f98099ec7456829f58047 authoraszlig <aszlig@redmoonstudios.org> dateTue 2 Feb 2016, 05:04 (11 years ago) parent52475af
2 files changed+48−34
pkgs/applications/networking/browsers/chromium/default.nix+4−7 pkgs/applications/networking/browsers/chromium/plugins.nix+44−27
pkgs/applications/networking/browsers/chromium/default.nix+4−7
@@ -64,20 +64,17 @@ let
6464in stdenv.mkDerivation {
6565 name = "chromium${suffix}-${chromium.browser.version}";
6666
67− buildInputs = [ makeWrapper ] ++ chromium.plugins.enabledPlugins;
67+ buildInputs = [ makeWrapper ];
6868
6969 buildCommand = let
7070 browserBinary = "${chromium.browser}/libexec/chromium/chromium";
71− mkEnvVar = key: val: "--set '${key}' '${val}'";
72− envVars = chromium.plugins.settings.envVars or {};
73− flags = chromium.plugins.settings.flags or [];
71+ getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")";
7472 in with stdenv.lib; ''
7573 mkdir -p "$out/bin" "$out/share/applications"
7674
7775 ln -s "${chromium.browser}/share" "$out/share"
78− makeWrapper "${browserBinary}" "$out/bin/chromium" \
79− ${concatStrings (mapAttrsToList mkEnvVar envVars)} \
80− --add-flags "${concatStringsSep " " flags}"
76+ eval makeWrapper "${browserBinary}" "$out/bin/chromium" \
77+ ${concatMapStringsSep " " getWrapperFlags chromium.plugins.enabled}
8178
8279 ln -s "$out/bin/chromium" "$out/bin/chromium-browser"
8380 ln -s "${chromium.browser}/share/icons" "$out/share/icons"
pkgs/applications/networking/browsers/chromium/plugins.nix+44−27
@@ -8,6 +8,34 @@
88with stdenv.lib;
99
1010let
11+ # Generate a shell fragment that emits flags appended to the
12+ # final makeWrapper call for wrapping the browser's main binary.
13+ #
14+ # Note that this is shell-escaped so that only the variable specified
15+ # by the "output" attribute is substituted.
16+ mkPluginInfo = { output ? "out", allowedVars ? [ output ]
17+ , flags ? [], envVars ? {}
18+ }: let
19+ shSearch = ["'"] ++ map (var: "\$${var}") allowedVars;
20+ shReplace = ["'\\''"] ++ map (var: "'\"\${${var}}\"'") allowedVars;
21+ # We need to triple-escape "val":
22+ # * First because makeWrapper doesn't do any quoting of its arguments by
23+ # itself.
24+ # * Second because it's passed to the makeWrapper call separated by IFS but
25+ # not by the _real_ arguments, for example the Widevine plugin flags
26+ # contain spaces, so they would end up as separate arguments.
27+ # * Third in order to be correctly quoted for the "echo" call below.
28+ shEsc = val: "'${replaceStrings ["'"] ["'\\''"] val}'";
29+ mkSh = val: "'${replaceStrings shSearch shReplace (shEsc val)}'";
30+ mkFlag = flag: ["--add-flags" (shEsc flag)];
31+ mkEnvVar = key: val: ["--set" (shEsc key) (shEsc val)];
32+ envList = mapAttrsToList mkEnvVar envVars;
33+ quoted = map mkSh (flatten ((map mkFlag flags) ++ envList));
34+ in ''
35+ mkdir -p "''$${output}/nix-support"
36+ echo ${toString quoted} > "''$${output}/nix-support/wrapper-flags"
37+ '';
38+
1139 plugins = stdenv.mkDerivation {
1240 name = "chromium-binary-plugins";
1341
@@ -61,40 +89,29 @@ let
6189
6290 install -vD PepperFlash/libpepflashplayer.so \
6391 "$flash/lib/libpepflashplayer.so"
64− mkdir -p "$flash/nix-support"
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
92+
93+ ${mkPluginInfo {
94+ output = "flash";
95+ allowedVars = [ "flash" "flashVersion" ];
96+ flags = [
97+ "--ppapi-flash-path=$flash/lib/libpepflashplayer.so"
98+ "--ppapi-flash-version=$flashVersion"
99+ ];
100+ }}
72101
73102 install -vD libwidevinecdm.so \
74103 "$widevine/lib/libwidevinecdm.so"
75104 install -vD libwidevinecdmadapter.so \
76105 "$widevine/lib/libwidevinecdmadapter.so"
77− mkdir -p "$widevine/nix-support"
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
106+
107+ ${mkPluginInfo {
108+ output = "widevine";
109+ flags = [ "--register-pepper-plugins=${wvModule}${wvInfo}" ];
110+ envVars.NIX_CHROMIUM_PLUGIN_PATH_WIDEVINE = "$widevine/lib";
111+ }}
83112 '';
84113
85− passthru = let
86− enabledPlugins = optional enablePepperFlash plugins.flash
114+ passthru.enabled = optional enablePepperFlash plugins.flash
87115 ++ optional enableWideVine plugins.widevine;
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 ]) {};
95− in {
96− inherit enabledPlugins;
97− settings = mergeAttrsets (map getNix enabledPlugins);
98− };
99116 };
100117in plugins