|
1 |
| -{ stdenv, lib, fetchurl, pkgconfig, which, m4, gtk2, pango, perl, python2, zip, libIDL |
2 |
| -, libjpeg, libpng, zlib, dbus, dbus_glib, bzip2, xorg |
3 |
| -, freetype, fontconfig, file, alsaLib, nspr, nss, libnotify |
4 |
| -, yasm, mesa, sqlite, unzip, makeWrapper |
5 |
| -, hunspell, libevent, libstartup_notification, libvpx |
6 |
| -, cairo, gstreamer, gst-plugins-base, icu |
| 1 | +{ lib, stdenv, fetchurl, pkgconfig, gtk2, pango, perl, python, zip, libIDL |
| 2 | +, libjpeg, zlib, dbus, dbus_glib, bzip2, xorg |
| 3 | +, freetype, fontconfig, file, nspr, nss, libnotify |
| 4 | +, yasm, mesa, sqlite, unzip |
| 5 | +, hunspell, libevent, libstartup_notification |
| 6 | +, cairo, gstreamer, gst-plugins-base, icu, libpng, jemalloc |
| 7 | +, autoconf213, which, m4 |
7 | 8 | , writeScript, xidel, common-updater-scripts, coreutils, gnused, gnugrep, curl
|
| 9 | +, enableGTK3 ? false, gtk3, gnome3, wrapGAppsHook, makeWrapper |
| 10 | +, enableCalendar ? true |
8 | 11 | , debugBuild ? false
|
9 |
| -, # If you want the resulting program to call itself "Thunderbird" |
10 |
| - # instead of "Earlybird", enable this option. However, those |
| 12 | +, # If you want the resulting program to call itself "Thunderbird" instead |
| 13 | + # of "Earlybird" or whatever, enable this option. However, those |
11 | 14 | # binaries may not be distributed without permission from the
|
12 | 15 | # Mozilla Foundation, see
|
13 | 16 | # http://www.mozilla.org/foundation/trademarks/.
|
14 | 17 | enableOfficialBranding ? false
|
| 18 | +, makeDesktopItem |
15 | 19 | }:
|
16 | 20 |
|
17 |
| -let version = "45.8.0"; in |
18 |
| -let verName = "${version}"; in |
19 |
| - |
20 |
| -stdenv.mkDerivation rec { |
21 |
| - name = "thunderbird-${verName}"; |
| 21 | +let |
| 22 | + wrapperTool = if enableGTK3 then wrapGAppsHook else makeWrapper; |
| 23 | +in stdenv.mkDerivation rec { |
| 24 | + name = "thunderbird-${version}"; |
| 25 | + version = "52.1.1"; |
22 | 26 |
|
23 | 27 | src = fetchurl {
|
24 |
| - url = "mirror://mozilla/thunderbird/releases/${verName}/source/thunderbird-${verName}.source.tar.xz"; |
25 |
| - sha512 = "f8ba08d874fb1a09ac9ba5d4d1f46cefe801783ba4bf82eee682ac2ecc4e231d07033a80e036ad04bda7780c093fb7bc3122a23dc6e19c12f18fb7168dc78deb"; |
| 28 | + url = "mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz"; |
| 29 | + sha512 = "84b54ae4401c9728c38f32f58e0df24e049471b3613f9973981b305e0ed09b2e8c2c1b5a35d4fee85ce2cf1d6fa99e80418bc216ae0d35d40e9fdeef61a6c06e"; |
26 | 30 | };
|
27 | 31 |
|
28 |
| - patches = [ ./gcc6.patch ]; |
29 |
| - |
30 | 32 | # New sed no longer tolerates this mistake.
|
31 | 33 | postPatch = ''
|
32 | 34 | for f in mozilla/{js/src,}/configure; do
|
33 | 35 | substituteInPlace "$f" --replace '[:space:]*' '[[:space:]]*'
|
34 | 36 | done
|
35 | 37 | '';
|
36 | 38 |
|
37 |
| - buildInputs = # from firefox30Pkgs.xulrunner, without gstreamer and libvpx |
38 |
| - [ pkgconfig which libpng gtk2 perl zip libIDL libjpeg zlib bzip2 |
39 |
| - python2 dbus dbus_glib pango freetype fontconfig xorg.libXi |
| 39 | + # from firefox, but without sound libraries |
| 40 | + buildInputs = |
| 41 | + [ gtk2 zip libIDL libjpeg zlib bzip2 |
| 42 | + dbus dbus_glib pango freetype fontconfig xorg.libXi |
40 | 43 | xorg.libX11 xorg.libXrender xorg.libXft xorg.libXt file
|
41 |
| - alsaLib nspr nss libnotify xorg.pixman yasm mesa |
| 44 | + nspr nss libnotify xorg.pixman yasm mesa |
42 | 45 | xorg.libXScrnSaver xorg.scrnsaverproto
|
43 |
| - xorg.libXext xorg.xextproto sqlite unzip makeWrapper |
44 |
| - hunspell libevent libstartup_notification cairo icu |
45 |
| - ] ++ [ m4 ]; |
| 46 | + xorg.libXext xorg.xextproto sqlite unzip |
| 47 | + hunspell libevent libstartup_notification /* cairo */ |
| 48 | + icu libpng jemalloc |
| 49 | + ] |
| 50 | + ++ lib.optionals enableGTK3 [ gtk3 gnome3.defaultIconTheme ]; |
| 51 | + |
| 52 | + # from firefox + m4 + wrapperTool |
| 53 | + nativeBuildInputs = [ m4 autoconf213 which gnused pkgconfig perl python wrapperTool ]; |
| 54 | + |
| 55 | + configureFlags = |
| 56 | + [ # from firefox, but without sound libraries (alsa, libvpx, pulseaudio) |
| 57 | + "--enable-application=mail" |
| 58 | + "--disable-alsa" |
| 59 | + "--disable-pulseaudio" |
46 | 60 |
|
47 |
| - configurePhase = let configureFlags = [ "--enable-application=mail" ] |
48 |
| - # from firefox30Pkgs.commonConfigureFlags, but without gstreamer and libvpx |
49 |
| - ++ [ |
50 | 61 | "--with-system-jpeg"
|
51 | 62 | "--with-system-zlib"
|
52 | 63 | "--with-system-bz2"
|
53 | 64 | "--with-system-nspr"
|
54 | 65 | "--with-system-nss"
|
55 | 66 | "--with-system-libevent"
|
56 |
| - #"--with-system-libvpx" |
57 |
| - "--with-system-png" |
| 67 | + "--with-system-png" # needs APNG support |
58 | 68 | "--with-system-icu"
|
59 | 69 | "--enable-system-ffi"
|
60 | 70 | "--enable-system-hunspell"
|
61 | 71 | "--enable-system-pixman"
|
62 | 72 | "--enable-system-sqlite"
|
63 | 73 | #"--enable-system-cairo"
|
64 |
| - "--disable-gconf" |
65 |
| - "--disable-gstreamer" |
66 | 74 | "--enable-startup-notification"
|
67 |
| - # "--enable-content-sandbox" # available since 26.0, but not much info available |
68 |
| - # "--enable-content-sandbox-reporter" # keeping disabled for now |
| 75 | + "--enable-content-sandbox" # available since 26.0, but not much info available |
69 | 76 | "--disable-crashreporter"
|
70 | 77 | "--disable-tests"
|
71 | 78 | "--disable-necko-wifi" # maybe we want to enable this at some point
|
72 |
| - "--disable-installer" |
73 | 79 | "--disable-updater"
|
74 |
| - "--disable-pulseaudio" |
75 |
| - ] ++ (if debugBuild then [ "--enable-debug" "--enable-profiling"] |
| 80 | + "--enable-jemalloc" |
| 81 | + "--disable-gconf" |
| 82 | + "--enable-default-toolkit=cairo-gtk${if enableGTK3 then "3" else "2"}" |
| 83 | + ] |
| 84 | + ++ lib.optional enableCalendar "--enable-calendar" |
| 85 | + ++ (if debugBuild then [ "--enable-debug" "--enable-profiling"] |
76 | 86 | else [ "--disable-debug" "--enable-release"
|
77 | 87 | "--disable-debug-symbols"
|
78 | 88 | "--enable-optimize" "--enable-strip" ])
|
79 |
| - ++ [ |
80 |
| - "--disable-javaxpcom" |
81 |
| - #"--enable-stdcxx-compat" # Avoid dependency on libstdc++ 4.7 |
82 |
| - ] |
83 |
| - ++ stdenv.lib.optional enableOfficialBranding "--enable-official-branding"; |
84 |
| - in '' |
85 |
| - mkdir -p objdir/mozilla |
86 |
| - cd objdir |
87 |
| - echo '${stdenv.lib.concatMapStrings (s : "ac_add_options ${s}\n") configureFlags}' > .mozconfig |
88 |
| - echo 'ac_add_options --prefix="'"$out"'"' >> .mozconfig |
89 |
| - # From version 38, we need to specify the source directory to build |
90 |
| - # Thunderbird. Refer to mozilla/configure and search a line with |
91 |
| - # "checking for application to build" and "# Support comm-central". |
92 |
| - echo 'ac_add_options --with-external-source-dir="'`realpath ..`'"' >> .mozconfig |
93 |
| - echo 'mk_add_options MOZ_MAKE_FLAGS="-j'"$NIX_BUILD_CORES"'"' >> .mozconfig |
94 |
| - echo 'mk_add_options MOZ_OBJDIR="'`pwd`'"' >> .mozconfig |
95 |
| -
|
96 |
| - export MOZCONFIG=`realpath ./.mozconfig` |
97 |
| -
|
98 |
| - patchShebangs ../mozilla/mach |
99 |
| - ../mozilla/mach configure |
100 |
| - ''; |
| 89 | + ++ lib.optional enableOfficialBranding "--enable-official-branding"; |
101 | 90 |
|
102 | 91 | enableParallelBuilding = true;
|
103 |
| - requiredSystemFeatures = [ "big-parallel" ]; |
104 | 92 |
|
105 |
| - buildPhase = "../mozilla/mach build"; |
| 93 | + preConfigure = |
| 94 | + '' |
| 95 | + configureScript="$(realpath ./configure)" |
| 96 | + mkdir ../objdir |
| 97 | + cd ../objdir |
| 98 | + ''; |
| 99 | + |
| 100 | + preInstall = |
| 101 | + '' |
| 102 | + # The following is needed for startup cache creation on grsecurity kernels. |
| 103 | + paxmark m ../objdir/dist/bin/xpcshell |
| 104 | + ''; |
106 | 105 |
|
107 |
| - installPhase = |
| 106 | + dontWrapGApps = true; # we do it ourselves |
| 107 | + postInstall = |
108 | 108 | ''
|
109 |
| - ../mozilla/mach install |
| 109 | + # For grsecurity kernels |
| 110 | + paxmark m $out/lib/thunderbird-[0-9]*/thunderbird |
110 | 111 |
|
| 112 | + # TODO: Move to a dev output? |
111 | 113 | rm -rf $out/include $out/lib/thunderbird-devel-* $out/share/idl
|
112 | 114 |
|
113 |
| - # Create a desktop item. |
114 |
| - mkdir -p $out/share/applications |
115 |
| - cat > $out/share/applications/thunderbird.desktop <<EOF |
116 |
| - [Desktop Entry] |
117 |
| - Type=Application |
118 |
| - Exec=$out/bin/thunderbird |
119 |
| - Icon=$out/lib/thunderbird-${version}/chrome/icons/default/default256.png |
120 |
| - Name=Thunderbird |
121 |
| - GenericName=Mail Reader |
122 |
| - Categories=Application;Network; |
123 |
| - EOF |
| 115 | + # $binary is a symlink to $target. |
| 116 | + # We wrap $target by replacing the $binary symlink. |
| 117 | + local target="$out/lib/thunderbird-${version}/thunderbird" |
| 118 | + local binary="$out/bin/thunderbird" |
| 119 | +
|
| 120 | + # Wrap correctly, this is needed to |
| 121 | + # 1) find Mozilla runtime, because argv0 must be the real thing, |
| 122 | + # or a symlink thereto. It cannot be the wrapper itself |
| 123 | + # 2) detect itself as the default mailreader across builds |
| 124 | + gappsWrapperArgs+=( |
| 125 | + --argv0 "$target" |
| 126 | + --set MOZ_APP_LAUNCHER thunderbird |
| 127 | + ) |
| 128 | + ${ |
| 129 | + # We wrap manually because wrapGAppsHook does not detect the symlink |
| 130 | + # To mimic wrapGAppsHook, we run it with dontWrapGApps, so |
| 131 | + # gappsWrapperArgs gets defined correctly |
| 132 | + lib.optionalString enableGTK3 "wrapGAppsHook" |
| 133 | + } |
| 134 | +
|
| 135 | + # "$binary" is a symlink, replace it by the wrapper |
| 136 | + rm "$binary" |
| 137 | + makeWrapper "$target" "$binary" "''${gappsWrapperArgs[@]}" |
| 138 | +
|
| 139 | + ${ let desktopItem = makeDesktopItem { |
| 140 | + name = "thunderbird"; |
| 141 | + exec = "thunderbird %U"; |
| 142 | + desktopName = "Thunderbird"; |
| 143 | + icon = "$out/lib/thunderbird-${version}/chrome/icons/default/default256.png"; |
| 144 | + genericName = "Main Reader"; |
| 145 | + categories = "Application;Network"; |
| 146 | + mimeType = stdenv.lib.concatStringsSep ";" [ |
| 147 | + # Email |
| 148 | + "x-scheme-handler/mailto" |
| 149 | + "message/rfc822" |
| 150 | + # Newsgroup |
| 151 | + "x-scheme-handler/news" |
| 152 | + "x-scheme-handler/snews" |
| 153 | + "x-scheme-handler/nntp" |
| 154 | + # Feed |
| 155 | + "x-scheme-handler/feed" |
| 156 | + "application/rss+xml" |
| 157 | + "application/x-extension-rss" |
| 158 | + ]; |
| 159 | + }; in desktopItem.buildCommand |
| 160 | + } |
124 | 161 | '';
|
125 | 162 |
|
126 |
| - postFixup = |
127 |
| - '' |
128 |
| - paxmark m $out/lib/thunderbird-${version}/thunderbird |
129 |
| - ''; |
| 163 | + postFixup = |
| 164 | + # Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712. |
| 165 | + '' |
| 166 | + patchelf --set-rpath "${lib.getLib libnotify |
| 167 | + }/lib:$(patchelf --print-rpath "$out"/lib/thunderbird-*/libxul.so)" \ |
| 168 | + "$out"/lib/thunderbird-*/libxul.so |
| 169 | + ''; |
| 170 | + |
| 171 | + doInstallCheck = true; |
| 172 | + installCheckPhase = |
| 173 | + '' |
| 174 | + # Some basic testing |
| 175 | + "$out/bin/thunderbird" --version |
| 176 | + ''; |
130 | 177 |
|
131 | 178 | meta = with stdenv.lib; {
|
132 | 179 | description = "A full-featured e-mail client";
|
|
1 commit comments
vcunat commentedon Jun 13, 2017
To be clear, all changes to thunderbird directly were picked, except that it still defaults to gtk2.