@@ -0,0 +1,136 @@
1+{ dpkg, fetchurl, lib, pkgs, stdenv, config
2+, alsaLib
3+, atk
4+, cairo
5+, coreutils
6+, cups
7+, dbus
8+, desktop_file_utils
9+, expat
10+, fontconfig
11+, freetype
12+, gcc-unwrapped
13+, gdk_pixbuf
14+, glib
15+, gnome2
16+, libgcrypt
17+, libgnome_keyring
18+, libnotify
19+, makeWrapper
20+, nodejs
21+, nspr
22+, nss
23+, pango
24+, python2
25+, udev
26+, wget
27+, xorg
28+}:
29+
30+stdenv.mkDerivation rec {
31+ name = "${pkgname}-${version}";
32+ pkgname = "nylas-mail-bin";
33+ version = "2.0.32";
34+ subVersion = "fec7941";
35+
36+ src =
37+ if stdenv.system == "x86_64-linux" then
38+ fetchurl {
39+ url = "https://edgehill.s3-us-west-2.amazonaws.com/${version}-${subVersion}/linux-deb/x64/NylasMail.deb";
40+ sha256 = "40060aa1dc3b5187b8ed4a07b9de3427e3c5a291df98c2c82395647fa2aa4ada";
41+ }
42+ else
43+ throw "NylasMail is not supported on ${stdenv.system}";
44+
45+ propagatedBuildInputs = [
46+ alsaLib
47+ atk
48+ cairo
49+ coreutils
50+ cups
51+ dbus
52+ desktop_file_utils
53+ expat
54+ fontconfig
55+ freetype
56+ gcc-unwrapped
57+ gdk_pixbuf
58+ glib
59+ gnome2.GConf
60+ gnome2.gtk
61+ libgnome_keyring
62+ libnotify
63+ nodejs
64+ nspr
65+ nss
66+ pango
67+ python2
68+ udev
69+ wget
70+ xorg.libX11
71+ xorg.libXScrnSaver
72+ xorg.libXcomposite
73+ xorg.libXcursor
74+ xorg.libXdamage
75+ xorg.libXext
76+ xorg.libXfixes
77+ xorg.libXi
78+ xorg.libXrandr
79+ xorg.libXrender
80+ xorg.libXtst
81+ xorg.libxkbfile
82+ ];
83+
84+
85+ buildInputs = [ gnome2.gnome_keyring ];
86+
87+ nativeBuildInputs = [ makeWrapper ];
88+
89+ buildCommand = ''
90+ mkdir -p $out
91+
92+ ${dpkg}/bin/dpkg-deb -x $src unpacked
93+ mv unpacked/usr/* $out/
94+
95+ # Fix path in desktop file
96+ substituteInPlace $out/share/applications/nylas-mail.desktop \
97+ --replace /usr/bin/nylas-mail $out/bin/nylas-mail
98+
99+ # Patch librariess
100+ noderp=$(patchelf --print-rpath $out/share/nylas-mail/libnode.so)
101+ patchelf --set-rpath $noderp:$out/lib:${stdenv.cc.cc.lib}/lib:${xorg.libxkbfile.out}/lib:${lib.makeLibraryPath propagatedBuildInputs } \
102+ $out/share/nylas-mail/libnode.so
103+
104+ ffrp=$(patchelf --print-rpath $out/share/nylas-mail/libffmpeg.so)
105+ patchelf --set-rpath $ffrp:$out/lib:${stdenv.cc.cc.lib}/lib:${lib.makeLibraryPath propagatedBuildInputs } \
106+ $out/share/nylas-mail/libffmpeg.so
107+
108+ # Patch binaries
109+ binrp=$(patchelf --print-rpath $out/share/nylas-mail/nylas)
110+ patchelf --interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) \
111+ --set-rpath $binrp:$out/lib:${stdenv.cc.cc.lib}/lib:${lib.makeLibraryPath propagatedBuildInputs } \
112+ $out/share/nylas-mail/nylas
113+
114+ wrapProgram $out/share/nylas-mail/nylas --set LD_LIBRARY_PATH "${xorg.libxkbfile}/lib:${pkgs.gnome3.libgnome_keyring}/lib";
115+
116+ # Fix path to bash so apm can install plugins.
117+ substituteInPlace $out/share/nylas-mail/resources/apm/bin/apm \
118+ --replace /bin/bash ${stdenv.shell}
119+
120+ wrapProgram $out/share/nylas-mail/resources/apm/bin/apm \
121+ --set PATH "${coreutils}/bin"
122+ patchelf --interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) \
123+ --set-rpath ${gcc-unwrapped.lib}/lib $out/share/nylas-mail/resources/apm/bin/node
124+ '';
125+
126+ meta = with stdenv.lib; {
127+ description = "Open-source mail client built on the modern web with Electron, React, and Flux";
128+ longDescription = ''
129+ Nylas Mail is an open-source mail client built on the modern web with Electron, React, and Flux. It is designed to be extensible, so it's easy to create new experiences and workflows around email. Nylas Mail can be enabled with it's requirements by enabling 'services.nylas-mail.enable=true'. Alternatively, make sure to have services.gnome3.gnome-keyring.enable = true; in your configuration.nix before running nylas-mail. If you happen to miss this step, you should remove ~/.nylas-mail and "~/.config/Nylas Mail" for a blank setup".
130+ '';
131+ license = licenses.gpl3;
132+ maintainers = with maintainers; [ johnramsden ];
133+ homepage = https://nylas.com;
134+ platforms = [ "x86_64-linux" ];
135+ };
136+}