chromium: remove one layer of wrapper by using ed

This commit is contained in:
obadz 2016-08-19 19:18:14 +01:00
parent b0e11652f4
commit 4574f22841

View file

@ -1,4 +1,4 @@
{ newScope, stdenv, makeWrapper, makeDesktopItem, writeScript { newScope, stdenv, makeWrapper, makeDesktopItem, ed
# package customization # package customization
, channel ? "stable" , channel ? "stable"
@ -66,38 +66,36 @@ let
in stdenv.mkDerivation { in stdenv.mkDerivation {
name = "chromium${suffix}-${chromium.browser.version}"; name = "chromium${suffix}-${chromium.browser.version}";
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ed ];
outputs = ["out" "sandbox"]; outputs = ["out" "sandbox"];
buildCommand = let buildCommand = let
browserBinary = "${chromium.browser}/libexec/chromium/chromium"; browserBinary = "${chromium.browser}/libexec/chromium/chromium";
getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")"; getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")";
launchScript = writeScript "chromium" ''
#! ${stdenv.shell}
if [ -x "/var/setuid-wrappers/${sandboxExecutableName}" ]
then
export CHROME_DEVEL_SANDBOX="/var/setuid-wrappers/${sandboxExecutableName}"
else
export CHROME_DEVEL_SANDBOX="@sandbox@/bin/${sandboxExecutableName}"
fi
# libredirect causes chromium to deadlock on startup
export LD_PRELOAD="$(echo -n "$LD_PRELOAD" | tr ':' '\n' | grep -v /lib/libredirect\\.so$ | tr '\n' ':')"
exec @out@/bin/.chromium-wrapped "''${extraFlagsArray[@]}" "$@"
'';
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"
eval makeWrapper "${browserBinary}" "$out/bin/.chromium-wrapped" \ eval makeWrapper "${browserBinary}" "$out/bin/chromium" \
${concatMapStringsSep " " getWrapperFlags chromium.plugins.enabled} ${concatMapStringsSep " " getWrapperFlags chromium.plugins.enabled}
cp -v "${launchScript}" "$out/bin/chromium" ed -v -s "$out/bin/chromium" << EOF
substituteInPlace $out/bin/chromium --subst-var out --subst-var sandbox 2i
chmod 755 "$out/bin/chromium"
if [ -x "/var/setuid-wrappers/${sandboxExecutableName}" ]
then
export CHROME_DEVEL_SANDBOX="/var/setuid-wrappers/${sandboxExecutableName}"
else
export CHROME_DEVEL_SANDBOX="$sandbox/bin/${sandboxExecutableName}"
fi
# libredirect causes chromium to deadlock on startup
export LD_PRELOAD="\$(echo -n "\$LD_PRELOAD" | tr ':' '\n' | grep -v /lib/libredirect\\\\.so$ | tr '\n' ':')"
.
w
EOF
ln -sv "${chromium.browser.sandbox}" "$sandbox" ln -sv "${chromium.browser.sandbox}" "$sandbox"