atom: avoid using LD_PRELOAD. Fixes glibc compat issues

The wrapper for Atom was loading libraries via LD_PRELOAD, for example
libxkbfile. Now, if you installed atom via nix-env and happened to use a newer
nixpkgs for that than what your system environment is build against, you could
end up with an error like this:

```
uname: relocation error:
/nix/store/68sa3m89shpfaqq1b9xp5p1360vqhwx6-glibc-2.25/lib/libdl.so.2:
symbol _dl_catch_error, version GLIBC_PRIVATE not defined in file libc.so.6
with link time reference
```

This happens because atom calls the `uname` executable from the system to
determine the platform. Because that inherits the `LD_PRELOAD` environment
variable, so the libxkbfile library that the `atom` wrapper was build against
is loaded into `uname`. But since `atom` comes from `nix-env`, the `libxkbfile`
it was built with might be compiled against a newer version of `glibc` than
`uname`, which comes from the system, was! Having two versions of glibc loaded
into the same processes results in chaos.

To fix this, we avoid setting `LD_PRELOAD` and instead use patchelf to set the
correct RPATH. RPATH is not inherited by child processes, so the above issue
can no longer occur.

The only small complication here is that the library that actually loads
libxkbfile is not the atom binary itself, but a node extension that atom uses.
So instead of setting the RPATH on `atom` only, we also set the `rpath` on all
node extensions (`*.node`) the output.

+6 -5
+5 -4
pkgs/applications/editors/atom/default.nix
··· 1 - { stdenv, fetchurl, lib, makeWrapper, gvfs, atomEnv, libXScrnSaver, libxkbfile }: 2 3 stdenv.mkDerivation rec { 4 name = "atom-${version}"; ··· 21 rm -r $out/share/lintian 22 rm -r $out/usr/ 23 wrapProgram $out/bin/atom \ 24 - --prefix "PATH" : "${gvfs}/bin" \ 25 - --prefix LD_PRELOAD : ${stdenv.lib.makeLibraryPath [ libXScrnSaver ]}/libXss.so.1 \ 26 - --prefix LD_PRELOAD : ${stdenv.lib.makeLibraryPath [ libxkbfile ]}/libxkbfile.so.1 27 28 fixupPhase 29 ··· 33 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 34 --set-rpath "${atomEnv.libPath}" \ 35 $out/share/atom/resources/app/apm/bin/node 36 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 37 $out/share/atom/resources/app.asar.unpacked/node_modules/symbols-view/vendor/ctags-linux 38 ''; 39 40 meta = with stdenv.lib; {
··· 1 + { stdenv, fetchurl, lib, makeWrapper, gvfs, atomEnv}: 2 3 stdenv.mkDerivation rec { 4 name = "atom-${version}"; ··· 21 rm -r $out/share/lintian 22 rm -r $out/usr/ 23 wrapProgram $out/bin/atom \ 24 + --prefix "PATH" : "${gvfs}/bin" 25 26 fixupPhase 27 ··· 31 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 32 --set-rpath "${atomEnv.libPath}" \ 33 $out/share/atom/resources/app/apm/bin/node 34 + 35 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 36 $out/share/atom/resources/app.asar.unpacked/node_modules/symbols-view/vendor/ctags-linux 37 + 38 + find $out/share/atom -name "*.node" -exec patchelf --set-rpath "${atomEnv.libPath}:$out/share/atom" {} \; 39 ''; 40 41 meta = with stdenv.lib; {
+1 -1
pkgs/applications/editors/atom/env.nix
··· 9 fontconfig gdk_pixbuf cairo cups expat libgpgerror alsaLib nspr gconf nss 10 xorg.libXrender xorg.libX11 xorg.libXext xorg.libXdamage xorg.libXtst 11 xorg.libXcomposite xorg.libXi xorg.libXfixes xorg.libXrandr 12 - xorg.libXcursor libcap systemd libnotify 13 ]; 14 15 libPathNative = lib.makeLibraryPath packages;
··· 9 fontconfig gdk_pixbuf cairo cups expat libgpgerror alsaLib nspr gconf nss 10 xorg.libXrender xorg.libX11 xorg.libXext xorg.libXdamage xorg.libXtst 11 xorg.libXcomposite xorg.libXi xorg.libXfixes xorg.libXrandr 12 + xorg.libXcursor xorg.libxkbfile xorg.libXScrnSaver libcap systemd libnotify 13 ]; 14 15 libPathNative = lib.makeLibraryPath packages;