a4d6e2cf16
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.
49 lines
1.6 KiB
Nix
49 lines
1.6 KiB
Nix
{ stdenv, fetchurl, lib, makeWrapper, gvfs, atomEnv}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
name = "atom-${version}";
|
|
version = "1.15.0";
|
|
|
|
src = fetchurl {
|
|
url = "https://github.com/atom/atom/releases/download/v${version}/atom-amd64.deb";
|
|
sha256 = "0w790b9m94m28bx7n94pg2zjxrcjf13228lsb0pl8kyfsk2k2glx";
|
|
name = "${name}.deb";
|
|
};
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildCommand = ''
|
|
mkdir -p $out/usr/
|
|
ar p $src data.tar.gz | tar -C $out -xz ./usr
|
|
substituteInPlace $out/usr/share/applications/atom.desktop \
|
|
--replace /usr/share/atom $out/bin
|
|
mv $out/usr/* $out/
|
|
rm -r $out/share/lintian
|
|
rm -r $out/usr/
|
|
wrapProgram $out/bin/atom \
|
|
--prefix "PATH" : "${gvfs}/bin"
|
|
|
|
fixupPhase
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
|
--set-rpath "${atomEnv.libPath}:$out/share/atom" \
|
|
$out/share/atom/atom
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
|
--set-rpath "${atomEnv.libPath}" \
|
|
$out/share/atom/resources/app/apm/bin/node
|
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
|
$out/share/atom/resources/app.asar.unpacked/node_modules/symbols-view/vendor/ctags-linux
|
|
|
|
find $out/share/atom -name "*.node" -exec patchelf --set-rpath "${atomEnv.libPath}:$out/share/atom" {} \;
|
|
'';
|
|
|
|
meta = with stdenv.lib; {
|
|
description = "A hackable text editor for the 21st Century";
|
|
homepage = https://atom.io/;
|
|
license = licenses.mit;
|
|
maintainers = [ maintainers.offline maintainers.nequissimus ];
|
|
platforms = [ "x86_64-linux" ];
|
|
};
|
|
}
|