summary refs log tree commit diff
path: root/pkgs/applications/networking/mailreaders/nylas-mail-bin/default.nix
blob: 76231dc7abf2f010f26dc504f4e63632892b65e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{ dpkg, fetchurl, lib, pkgs, stdenv, config
, alsaLib
, atk
, cairo
, coreutils
, cups
, dbus
, desktop_file_utils
, expat
, fontconfig
, freetype
, gcc-unwrapped
, gdk_pixbuf
, glib
, gnome2
, libgcrypt
, libgnome_keyring
, libnotify
, makeWrapper
, nodejs
, nspr
, nss
, pango
, python2
, udev
, wget
, xorg
}:

stdenv.mkDerivation rec {
  name = "${pkgname}-${version}";
  pkgname = "nylas-mail-bin";
  version = "2.0.32";
  subVersion = "fec7941";

  src =
    if stdenv.system == "x86_64-linux" then
      fetchurl {
        url = "https://edgehill.s3.amazonaws.com/${version}-${subVersion}/linux-deb/x64/NylasMail.deb";
        sha256 = "40060aa1dc3b5187b8ed4a07b9de3427e3c5a291df98c2c82395647fa2aa4ada";
      }
    else
      throw "NylasMail is not supported on ${stdenv.system}";

  propagatedBuildInputs = [
    alsaLib
    atk
    cairo
    coreutils
    cups
    dbus
    desktop_file_utils
    expat
    fontconfig
    freetype
    gcc-unwrapped
    gdk_pixbuf
    glib
    gnome2.GConf
    gnome2.gtk
    libgnome_keyring
    libnotify
    nodejs
    nspr
    nss
    pango
    python2
    udev
    wget
    xorg.libX11
    xorg.libXScrnSaver
    xorg.libXcomposite
    xorg.libXcursor
    xorg.libXdamage
    xorg.libXext
    xorg.libXfixes
    xorg.libXi
    xorg.libXrandr
    xorg.libXrender
    xorg.libXtst
    xorg.libxkbfile
  ];


  buildInputs = [ gnome2.gnome_keyring ];

  nativeBuildInputs = [ makeWrapper ];

  buildCommand = ''
    mkdir -p $out

    ${dpkg}/bin/dpkg-deb -x $src unpacked
    mv unpacked/usr/* $out/

    # Fix path in desktop file
    substituteInPlace $out/share/applications/nylas-mail.desktop \
      --replace /usr/bin/nylas-mail $out/bin/nylas-mail

    # Patch librariess
    noderp=$(patchelf --print-rpath $out/share/nylas-mail/libnode.so)
    patchelf --set-rpath $noderp:$out/lib:${stdenv.cc.cc.lib}/lib:${xorg.libxkbfile.out}/lib:${lib.makeLibraryPath propagatedBuildInputs } \
      $out/share/nylas-mail/libnode.so

    ffrp=$(patchelf --print-rpath $out/share/nylas-mail/libffmpeg.so)
    patchelf --set-rpath $ffrp:$out/lib:${stdenv.cc.cc.lib}/lib:${lib.makeLibraryPath propagatedBuildInputs } \
      $out/share/nylas-mail/libffmpeg.so

    # Patch binaries
    binrp=$(patchelf --print-rpath $out/share/nylas-mail/nylas)
    patchelf --interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) \
      --set-rpath $binrp:$out/lib:${stdenv.cc.cc.lib}/lib:${lib.makeLibraryPath propagatedBuildInputs } \
      $out/share/nylas-mail/nylas

    wrapProgram $out/share/nylas-mail/nylas --set LD_LIBRARY_PATH "${xorg.libxkbfile}/lib:${pkgs.gnome3.libgnome_keyring}/lib";

    # Fix path to bash so apm can install plugins.
    substituteInPlace $out/share/nylas-mail/resources/apm/bin/apm \
      --replace /bin/bash ${stdenv.shell}

    wrapProgram $out/share/nylas-mail/resources/apm/bin/apm \
      --set PATH "${coreutils}/bin"
    patchelf --interpreter $(cat "$NIX_CC"/nix-support/dynamic-linker) \
      --set-rpath ${gcc-unwrapped.lib}/lib $out/share/nylas-mail/resources/apm/bin/node
  '';

  meta = with stdenv.lib; {
    description = "Open-source mail client built on the modern web with Electron, React, and Flux";
    longDescription = ''
      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".
    '';
    license = licenses.gpl3;
    maintainers = with maintainers; [ johnramsden ];
    homepage = https://nylas.com;
    platforms = [ "x86_64-linux" ];
  };
}