google-chrome: passthrough CHROME_WRAPPER environment variable

The XDG desktop menu entries created by Chrome for Progressive Web Apps
are currently broken due to Exec being set to the path of the upstream
Chrome wrapper instead of the Nixpkgs wrapper. This causes Chrome to
crash becaues LD_LIBRARY_PATH is not set.

Chrome obtains the path to be included in the menu entry from the
CHROME_WRAPPER environment variable, which is currently set by the
upstream wrapper to its own path. By setting the variable to the path of
the Nixpkgs wrapper instead, launching PWAs works as expected.

https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/shell_integration_linux.cc
https://source.chromium.org/chromium/chromium/src/+/main:chrome/installer/linux/common/wrapper
This commit is contained in:
Brandon Weeks 2022-01-17 15:15:18 -08:00 committed by Michael Weiss
parent 189f73465b
commit 4ec7d05099
No known key found for this signature in database
GPG key ID: 5BE487C4D4771D83

View file

@ -118,6 +118,9 @@ in stdenv.mkDerivation {
cp -a opt/* $out/share
cp -a usr/share/* $out/share
substituteInPlace $out/share/google/$appname/google-$appname \
--replace 'CHROME_WRAPPER' 'WRAPPER'
substituteInPlace $out/share/applications/google-$appname.desktop \
--replace /usr/bin/google-chrome-$dist $exe
substituteInPlace $out/share/gnome-control-center/default-apps/google-$appname.xml \
@ -143,6 +146,7 @@ in stdenv.mkDerivation {
--prefix LD_LIBRARY_PATH : "$rpath" \
--prefix PATH : "$binpath" \
--prefix XDG_DATA_DIRS : "$XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH:${addOpenGLRunpath.driverLink}/share" \
--set CHROME_WRAPPER "google-chrome-$dist" \
--add-flags ${escapeShellArg commandLineArgs} \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"