2017-08-21 13:32:47 +01:00
|
|
|
{ stdenv, pkgs, fetchurl, lib, makeWrapper, gvfs, atomEnv}:
|
2014-06-07 11:45:33 +01:00
|
|
|
|
2016-04-22 11:51:11 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2014-06-07 11:45:33 +01:00
|
|
|
name = "atom-${version}";
|
2018-03-09 18:12:48 +00:00
|
|
|
version = "1.24.1";
|
2014-06-07 11:45:33 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2014-09-18 20:51:19 +01:00
|
|
|
url = "https://github.com/atom/atom/releases/download/v${version}/atom-amd64.deb";
|
2018-03-09 18:12:48 +00:00
|
|
|
sha256 = "0llg2q1hn2wmhi80ddwwb2lir2xwwmrw19i2c1y3qmfb0apynhw3";
|
2014-09-18 20:51:19 +01:00
|
|
|
name = "${name}.deb";
|
2014-06-07 11:45:33 +01:00
|
|
|
};
|
|
|
|
|
2016-04-13 16:30:38 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2014-06-07 11:45:33 +01:00
|
|
|
|
2016-04-22 11:51:11 +01:00
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/usr/
|
2017-06-16 13:09:15 +01:00
|
|
|
ar p $src data.tar.xz | tar -C $out -xJ ./usr
|
2015-06-19 22:10:05 +01:00
|
|
|
substituteInPlace $out/usr/share/applications/atom.desktop \
|
|
|
|
--replace /usr/share/atom $out/bin
|
2014-09-18 20:51:19 +01:00
|
|
|
mv $out/usr/* $out/
|
2015-06-19 22:10:05 +01:00
|
|
|
rm -r $out/share/lintian
|
2014-09-18 20:51:19 +01:00
|
|
|
rm -r $out/usr/
|
2016-04-22 11:51:11 +01:00
|
|
|
wrapProgram $out/bin/atom \
|
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.
2017-03-18 00:39:14 +00:00
|
|
|
--prefix "PATH" : "${gvfs}/bin"
|
2016-04-22 11:51:11 +01:00
|
|
|
|
2016-04-22 15:44:30 +01:00
|
|
|
fixupPhase
|
|
|
|
|
2014-12-17 18:11:30 +00:00
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
2016-04-22 11:51:11 +01:00
|
|
|
--set-rpath "${atomEnv.libPath}:$out/share/atom" \
|
2014-06-07 11:45:33 +01:00
|
|
|
$out/share/atom/atom
|
2014-12-17 18:11:30 +00:00
|
|
|
patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
|
2016-04-22 11:51:11 +01:00
|
|
|
--set-rpath "${atomEnv.libPath}" \
|
2015-03-12 16:41:41 +00:00
|
|
|
$out/share/atom/resources/app/apm/bin/node
|
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.
2017-03-18 00:39:14 +00:00
|
|
|
|
2017-10-05 15:12:41 +01:00
|
|
|
rm -f $out/share/atom/resources/app.asar.unpacked/node_modules/dugite/git/bin/git
|
|
|
|
ln -s ${pkgs.git}/bin/git $out/share/atom/resources/app.asar.unpacked/node_modules/dugite/git/bin/git
|
2017-08-21 13:32:47 +01:00
|
|
|
|
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.
2017-03-18 00:39:14 +00:00
|
|
|
find $out/share/atom -name "*.node" -exec patchelf --set-rpath "${atomEnv.libPath}:$out/share/atom" {} \;
|
2017-08-05 19:36:00 +01:00
|
|
|
|
|
|
|
paxmark m $out/share/atom/atom
|
|
|
|
paxmark m $out/share/atom/resources/app/apm/bin/node
|
2014-06-07 11:45:33 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "A hackable text editor for the 21st Century";
|
|
|
|
homepage = https://atom.io/;
|
2015-05-28 18:20:29 +01:00
|
|
|
license = licenses.mit;
|
2016-02-15 19:58:46 +00:00
|
|
|
maintainers = [ maintainers.offline maintainers.nequissimus ];
|
2014-06-07 11:45:33 +01:00
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|