summary refs log tree commit diff
path: root/pkgs/applications/networking/mailreaders/thunderbird/default.nix
blob: a328169df35d81ea0773d824a02889c1cc60fa6f (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
137
138
139
140
141
142
143
144
145
146
147
{ stdenv, fetchurl, pkgconfig, which, m4, gtk2, pango, perl, python2, zip, libIDL
, libjpeg, libpng, zlib, dbus, dbus_glib, bzip2, xorg
, freetype, fontconfig, file, alsaLib, nspr, nss, libnotify
, yasm, mesa, sqlite, unzip, makeWrapper
, hunspell, libevent, libstartup_notification, libvpx
, cairo, gstreamer, gst_plugins_base, icu
, writeScript, xidel, coreutils, gnused, gnugrep, curl, ed
, debugBuild ? false
, # If you want the resulting program to call itself "Thunderbird"
  # instead of "Earlybird", enable this option.  However, those
  # binaries may not be distributed without permission from the
  # Mozilla Foundation, see
  # http://www.mozilla.org/foundation/trademarks/.
  enableOfficialBranding ? false
}:

let version = "45.7.0"; in
let verName = "${version}"; in

stdenv.mkDerivation rec {
  name = "thunderbird-${verName}";

  src = fetchurl {
    url = "mirror://mozilla/thunderbird/releases/${verName}/source/thunderbird-${verName}.source.tar.xz";
    sha512 = "99cea54b553158c1e08cf19157ac2bb6822fd1fef0501d36f983e6b8d4f2143a2e6124d61297446944033d3fed9326fe0f12ca45db0b5815be71a0777e73ffb0";
  };

  # New sed no longer tolerates this mistake.
  postPatch = ''
    for f in mozilla/{js/src,}/configure; do
      substituteInPlace "$f" --replace '[:space:]*' '[[:space:]]*'
    done
  '';

  buildInputs = # from firefox30Pkgs.xulrunner, without gstreamer and libvpx
    [ pkgconfig which libpng gtk2 perl zip libIDL libjpeg zlib bzip2
      python2 dbus dbus_glib pango freetype fontconfig xorg.libXi
      xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
      alsaLib nspr nss libnotify xorg.pixman yasm mesa
      xorg.libXScrnSaver xorg.scrnsaverproto
      xorg.libXext xorg.xextproto sqlite unzip makeWrapper
      hunspell libevent libstartup_notification cairo icu
    ] ++ [ m4 ];

  configurePhase = let configureFlags = [ "--enable-application=mail" ]
    # from firefox30Pkgs.commonConfigureFlags, but without gstreamer and libvpx
    ++ [
      "--with-system-jpeg"
      "--with-system-zlib"
      "--with-system-bz2"
      "--with-system-nspr"
      "--with-system-nss"
      "--with-system-libevent"
      #"--with-system-libvpx"
      "--with-system-png"
      "--with-system-icu"
      "--enable-system-ffi"
      "--enable-system-hunspell"
      "--enable-system-pixman"
      "--enable-system-sqlite"
      "--enable-system-cairo"
      "--disable-gconf"
      "--disable-gstreamer"
      "--enable-startup-notification"
      # "--enable-content-sandbox"            # available since 26.0, but not much info available
      # "--enable-content-sandbox-reporter"   # keeping disabled for now
      "--disable-crashreporter"
      "--disable-tests"
      "--disable-necko-wifi" # maybe we want to enable this at some point
      "--disable-installer"
      "--disable-updater"
      "--disable-pulseaudio"
    ] ++ (if debugBuild then [ "--enable-debug" "--enable-profiling"]
                        else [ "--disable-debug" "--enable-release"
                               "--disable-debug-symbols"
                               "--enable-optimize" "--enable-strip" ])
    ++ [
      "--disable-javaxpcom"
      #"--enable-stdcxx-compat" # Avoid dependency on libstdc++ 4.7
    ]
    ++ stdenv.lib.optional enableOfficialBranding "--enable-official-branding";
  in ''
    mkdir -p objdir/mozilla
    cd objdir
    echo '${stdenv.lib.concatMapStrings (s : "ac_add_options ${s}\n") configureFlags}' > .mozconfig
    echo 'ac_add_options --prefix="'"$out"'"' >> .mozconfig
    # From version 38, we need to specify the source directory to build
    # Thunderbird. Refer to mozilla/configure and search a line with
    # "checking for application to build" and "# Support comm-central".
    echo 'ac_add_options --with-external-source-dir="'`realpath ..`'"' >> .mozconfig
    echo 'mk_add_options MOZ_MAKE_FLAGS="-j'"$NIX_BUILD_CORES"'"' >> .mozconfig
    echo 'mk_add_options MOZ_OBJDIR="'`pwd`'"' >> .mozconfig

    export MOZCONFIG=`realpath ./.mozconfig`

    patchShebangs ../mozilla/mach
    ../mozilla/mach configure
  '';

  enableParallelBuilding = true;
  requiredSystemFeatures = [ "big-parallel" ];

  buildPhase =  "../mozilla/mach build";

  installPhase =
    ''
      ../mozilla/mach install

      rm -rf $out/include $out/lib/thunderbird-devel-* $out/share/idl

      # Create a desktop item.
      mkdir -p $out/share/applications
      cat > $out/share/applications/thunderbird.desktop <<EOF
      [Desktop Entry]
      Type=Application
      Exec=$out/bin/thunderbird
      Icon=$out/lib/thunderbird-${version}/chrome/icons/default/default256.png
      Name=Thunderbird
      GenericName=Mail Reader
      Categories=Application;Network;
      EOF
    '';

    postFixup =
      ''
        paxmark m $out/lib/thunderbird-${version}/thunderbird
      '';

  meta = with stdenv.lib; {
    description = "A full-featured e-mail client";
    homepage = http://www.mozilla.org/thunderbird/;
    license =
      # Official branding implies thunderbird name and logo cannot be reuse,
      # see http://www.mozilla.org/foundation/licensing.html
      if enableOfficialBranding then licenses.proprietary else licenses.mpl11;
    maintainers = [ maintainers.pierron maintainers.eelco ];
    platforms = platforms.linux;
  };

  passthru.updateScript = import ./../../browsers/firefox/update.nix {
    name = "thunderbird";
    sourceSectionRegex = ".";
    basePath = "pkgs/applications/networking/mailreaders/thunderbird";
    baseUrl = "http://archive.mozilla.org/pub/thunderbird/releases/";
    inherit writeScript xidel coreutils gnused gnugrep curl ed;
  };
}