From a48211c319dc9520dbabfd20bd2001f991fd898e Mon Sep 17 00:00:00 2001 From: rikhuijzer Date: Fri, 3 Mar 2023 13:13:25 +0100 Subject: [PATCH] microsoft-edge: fix file picker and `subsituteInPlace` This fixes Microsoft Edge crashing if someone tries to open or save a file via the file picker. For example, to debug the functionality, I went to: ``` https://drive.google.com -> New -> File upload ``` This used to crash with the following error: ``` [...] (microsoft-edge:22536): GLib-GIO-ERROR **: 11:11:46.555: No GSettings schemas are installed on the system [0302/111146.559740:ERROR:elf_dynamic_array_reader.h(64)] tag not found [0302/111146.559913:ERROR:process_memory_range.cc(75)] read out of range [0302/111146.568118:ERROR:watson_metadata.cc(170)] unexpected header Trace/breakpoint trap (core dumped) ``` This PR fixes this error by explicitly making `gsettings-schemas` from `gtk` available to `microsoft-edge` via `XDG_DATA_DIRS`. Furthermore, this PR fixes some broken `subsituteInPlace` commands. Thanks to Jona Enzinger (`@JonaEnz`) who noticed that `--replace "''${XDG...` should be written as `--replace "\''${XDG...`. --- .../browsers/microsoft-edge/browser.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/networking/browsers/microsoft-edge/browser.nix b/pkgs/applications/networking/browsers/microsoft-edge/browser.nix index 636d1a13791f..685bd7e42ac8 100644 --- a/pkgs/applications/networking/browsers/microsoft-edge/browser.nix +++ b/pkgs/applications/networking/browsers/microsoft-edge/browser.nix @@ -3,6 +3,7 @@ { stdenv , fetchurl , lib +, makeWrapper , binutils-unwrapped , xz @@ -62,6 +63,10 @@ stdenv.mkDerivation rec { inherit sha256; }; + nativeBuildInputs = [ + makeWrapper + ]; + unpackCmd = "${binutils-unwrapped}/bin/ar p $src data.tar.xz | ${xz}/bin/xz -dc | ${gnutar}/bin/tar -xf -"; sourceRoot = "."; @@ -170,7 +175,7 @@ stdenv.mkDerivation rec { --replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName} substituteInPlace $out/opt/microsoft/${shortName}/xdg-mime \ - --replace "''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \ + --replace "\''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "\''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \ --replace "xdg_system_dirs=/usr/local/share/:/usr/share/" "xdg_system_dirs=/run/current-system/sw/share/" \ --replace /usr/bin/file ${file}/bin/file @@ -178,8 +183,13 @@ stdenv.mkDerivation rec { --replace /opt/microsoft/${shortName} $out/opt/microsoft/${shortName} substituteInPlace $out/opt/microsoft/${shortName}/xdg-settings \ - --replace "''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \ - --replace "''${XDG_CONFIG_DIRS:-/etc/xdg}" "''${XDG_CONFIG_DIRS:-/run/current-system/sw/etc/xdg}" + --replace "\''${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" "\''${XDG_DATA_DIRS:-/run/current-system/sw/share}" \ + --replace "\''${XDG_CONFIG_DIRS:-/etc/xdg}" "\''${XDG_CONFIG_DIRS:-/run/current-system/sw/etc/xdg}" + ''; + + postFixup = '' + wrapProgram "$out/bin/${longName}" \ + --prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.pname}-${gtk3.version}" ''; meta = with lib; {