summary refs log tree commit diff
path: root/pkgs/applications/networking/mailreaders/thunderbird
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2017-05-20 13:57:49 +0200
committerRobin Gloster <mail@glob.in>2017-05-20 14:55:44 +0200
commitda9adb8fab40a3dd86d6cfcbd103657ca98e5a48 (patch)
tree25c6af6c8753a49d4774eb901d9696ccefa9d461 /pkgs/applications/networking/mailreaders/thunderbird
parent9beb44fb84fa579edcbdb9089facce25248bac02 (diff)
parentc9f3893451103c52e70566a5d043ab5e35014e6c (diff)
downloadnixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.gz
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.bz2
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.lz
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.xz
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.tar.zst
nixlib-da9adb8fab40a3dd86d6cfcbd103657ca98e5a48.zip
Merge remote-tracking branch 'upstream/master' into gcc-6
Diffstat (limited to 'pkgs/applications/networking/mailreaders/thunderbird')
-rw-r--r--pkgs/applications/networking/mailreaders/thunderbird/default.nix209
1 files changed, 128 insertions, 81 deletions
diff --git a/pkgs/applications/networking/mailreaders/thunderbird/default.nix b/pkgs/applications/networking/mailreaders/thunderbird/default.nix
index 89cdfcb1aa43..9fe5a82769eb 100644
--- a/pkgs/applications/networking/mailreaders/thunderbird/default.nix
+++ b/pkgs/applications/networking/mailreaders/thunderbird/default.nix
@@ -1,28 +1,32 @@
-{ 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
+{ lib, stdenv, fetchurl, pkgconfig, gtk2, pango, perl, python, zip, libIDL
+, libjpeg, zlib, dbus, dbus_glib, bzip2, xorg
+, freetype, fontconfig, file, nspr, nss, libnotify
+, yasm, mesa, sqlite, unzip
+, hunspell, libevent, libstartup_notification
+, cairo, gstreamer, gst-plugins-base, icu, libpng, jemalloc
+, autoconf213, which, m4
+, writeScript, xidel, common-updater-scripts, coreutils, gnused, gnugrep, curl
+, enableGTK3 ? false, gtk3, gnome3, wrapGAppsHook, makeWrapper
+, enableCalendar ? true
 , debugBuild ? false
-, # If you want the resulting program to call itself "Thunderbird"
-  # instead of "Earlybird", enable this option.  However, those
+, # If you want the resulting program to call itself "Thunderbird" instead
+  # of "Earlybird" or whatever, 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
+, makeDesktopItem
 }:
 
-let version = "45.6.0"; in
-let verName = "${version}"; in
-
-stdenv.mkDerivation rec {
-  name = "thunderbird-${verName}";
+let
+  wrapperTool = if enableGTK3 then wrapGAppsHook else makeWrapper;
+in stdenv.mkDerivation rec {
+  name = "thunderbird-${version}";
+  version = "52.1.1";
 
   src = fetchurl {
-    url = "mirror://mozilla/thunderbird/releases/${verName}/source/thunderbird-${verName}.source.tar.xz";
-    sha512 = "1f4579ac37b8ab98c91fe2e3e6742ba1b005ca9346d23f467d19e6af45eb457cab749bf91ed2a79f2058bd66f54da661da3ea5d5786f8c4b472d8a2a6c34db4b";
+    url = "mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz";
+    sha512 = "84b54ae4401c9728c38f32f58e0df24e049471b3613f9973981b305e0ed09b2e8c2c1b5a35d4fee85ce2cf1d6fa99e80418bc216ae0d35d40e9fdeef61a6c06e";
   };
 
   patches = [ ./gcc6.patch ];
@@ -34,99 +38,144 @@ stdenv.mkDerivation rec {
     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
+  # from firefox, but without sound libraries
+  buildInputs =
+    [ gtk2 zip libIDL libjpeg zlib bzip2
+      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
+      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 ];
+      xorg.libXext xorg.xextproto sqlite unzip
+      hunspell libevent libstartup_notification /* cairo */
+      icu libpng jemalloc
+    ]
+    ++ lib.optionals enableGTK3 [ gtk3 gnome3.defaultIconTheme ];
+
+  # from firefox + m4 + wrapperTool
+  nativeBuildInputs = [ m4 autoconf213 which gnused pkgconfig perl python wrapperTool ];
+
+  configureFlags =
+    [ # from firefox, but without sound libraries (alsa, libvpx, pulseaudio)
+      "--enable-application=mail"
+      "--disable-alsa"
+      "--disable-pulseaudio"
 
-  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-png" # needs APNG support
       "--with-system-icu"
       "--enable-system-ffi"
       "--enable-system-hunspell"
       "--enable-system-pixman"
       "--enable-system-sqlite"
-      "--enable-system-cairo"
-      "--disable-gconf"
-      "--disable-gstreamer"
+      #"--enable-system-cairo"
       "--enable-startup-notification"
-      # "--enable-content-sandbox"            # available since 26.0, but not much info available
-      # "--enable-content-sandbox-reporter"   # keeping disabled for now
+      "--enable-content-sandbox"            # available since 26.0, but not much info available
       "--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"]
+      "--enable-jemalloc"
+      "--disable-gconf"
+      "--enable-default-toolkit=cairo-gtk${if enableGTK3 then "3" else "2"}"
+    ]
+      ++ lib.optional enableCalendar "--enable-calendar"
+      ++ (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
-  '';
+      ++ lib.optional enableOfficialBranding "--enable-official-branding";
 
   enableParallelBuilding = true;
-  requiredSystemFeatures = [ "big-parallel" ];
 
-  buildPhase =  "../mozilla/mach build";
+  preConfigure =
+    ''
+      configureScript="$(realpath ./configure)"
+      mkdir ../objdir
+      cd ../objdir
+    '';
+
+  preInstall =
+    ''
+      # The following is needed for startup cache creation on grsecurity kernels.
+      paxmark m ../objdir/dist/bin/xpcshell
+    '';
 
-  installPhase =
+  dontWrapGApps = true; # we do it ourselves
+  postInstall =
     ''
-      ../mozilla/mach install
+      # For grsecurity kernels
+      paxmark m $out/lib/thunderbird-[0-9]*/thunderbird
 
+      # TODO: Move to a dev output?
       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
+      # $binary is a symlink to $target.
+      # We wrap $target by replacing the $binary symlink.
+      local target="$out/lib/thunderbird-${version}/thunderbird"
+      local binary="$out/bin/thunderbird"
+
+      # Wrap correctly, this is needed to
+      # 1) find Mozilla runtime, because argv0 must be the real thing,
+      #    or a symlink thereto. It cannot be the wrapper itself
+      # 2) detect itself as the default mailreader across builds
+      gappsWrapperArgs+=(
+        --argv0 "$target"
+        --set MOZ_APP_LAUNCHER thunderbird
+      )
+      ${
+        # We wrap manually because wrapGAppsHook does not detect the symlink
+        # To mimic wrapGAppsHook, we run it with dontWrapGApps, so
+        # gappsWrapperArgs gets defined correctly
+        lib.optionalString enableGTK3 "wrapGAppsHook"
+      }
+
+      # "$binary" is a symlink, replace it by the wrapper
+      rm "$binary"
+      makeWrapper "$target" "$binary" "''${gappsWrapperArgs[@]}"
+
+      ${ let desktopItem = makeDesktopItem {
+          name = "thunderbird";
+          exec = "thunderbird %U";
+          desktopName = "Thunderbird";
+          icon = "$out/lib/thunderbird-${version}/chrome/icons/default/default256.png";
+          genericName = "Main Reader";
+          categories = "Application;Network";
+          mimeType = stdenv.lib.concatStringsSep ";" [
+            # Email
+            "x-scheme-handler/mailto"
+            "message/rfc822"
+            # Newsgroup
+            "x-scheme-handler/news"
+            "x-scheme-handler/snews"
+            "x-scheme-handler/nntp"
+            # Feed
+            "x-scheme-handler/feed"
+            "application/rss+xml"
+            "application/x-extension-rss"
+          ];
+        }; in desktopItem.buildCommand
+      }
     '';
 
-    postFixup =
-      ''
-        paxmark m $out/lib/thunderbird-${version}/thunderbird
-      '';
+  postFixup =
+    # Fix notifications. LibXUL uses dlopen for this, unfortunately; see #18712.
+    ''
+      patchelf --set-rpath "${lib.getLib libnotify
+        }/lib:$(patchelf --print-rpath "$out"/lib/thunderbird-*/libxul.so)" \
+          "$out"/lib/thunderbird-*/libxul.so
+    '';
+
+  doInstallCheck = true;
+  installCheckPhase =
+    ''
+      # Some basic testing
+      "$out/bin/thunderbird" --version
+    '';
 
   meta = with stdenv.lib; {
     description = "A full-featured e-mail client";
@@ -140,10 +189,8 @@ stdenv.mkDerivation rec {
   };
 
   passthru.updateScript = import ./../../browsers/firefox/update.nix {
-    name = "thunderbird";
-    sourceSectionRegex = ".";
-    basePath = "pkgs/applications/networking/mailreaders/thunderbird";
+    attrPath = "thunderbird";
     baseUrl = "http://archive.mozilla.org/pub/thunderbird/releases/";
-    inherit writeScript xidel coreutils gnused gnugrep curl ed;
+    inherit writeScript lib common-updater-scripts xidel coreutils gnused gnugrep curl;
   };
 }