thunderbird: use firefox expression

This commit is contained in:
Yureka 2021-07-13 19:13:53 +02:00
parent 711d674e13
commit 8b1c14045d
7 changed files with 90 additions and 405 deletions

@ -1,357 +0,0 @@
{ autoconf213
, bzip2
, cargo
, common-updater-scripts
, copyDesktopItems
, coreutils
, curl
, dbus
, dbus-glib
, fetchpatch
, fetchurl
, file
, fontconfig
, freetype
, glib
, gnugrep
, gnupg
, gnused
, gpgme
, icu
, jemalloc
, lib
, libevent
, libGL
, libGLU
, libjpeg
, libnotify
, libpng
, libstartup_notification
, libvpx
, libwebp
, llvmPackages
, m4
, makeDesktopItem
, nasm
, nodejs
, nspr
, nss_3_53
, pango
, perl
, pkg-config
, python2
, python3
, runtimeShell
, rust-cbindgen
, rustc
, sqlite
, stdenv
, systemd
, unzip
, which
, writeScript
, xdg-utils
, xidel
, xorg
, yasm
, zip
, zlib
, debugBuild ? false
, alsaSupport ? stdenv.isLinux, alsa-lib
, pulseaudioSupport ? stdenv.isLinux, libpulseaudio
, gtk3Support ? true, gtk2, gtk3, wrapGAppsHook
, waylandSupport ? true, libdrm
, libxkbcommon, calendarSupport ? true
# Use official trademarked branding. Permission obtained at:
# https://github.com/NixOS/nixpkgs/pull/94880#issuecomment-675907971
, enableOfficialBranding ? true
}:
assert waylandSupport -> gtk3Support == true;
stdenv.mkDerivation rec {
pname = "thunderbird";
version = "78.13.0";
src = fetchurl {
url =
"mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz";
sha512 =
"daee9ea9e57bdfce231a35029807f279a06f8790d71efc8998c78eb42d99a93cf98623170947df99202da038f949ba9111a7ff7adbd43c161794deb6791370a0";
};
nativeBuildInputs = [
autoconf213
cargo
copyDesktopItems
gnused
llvmPackages.llvm
m4
nasm
nodejs
perl
pkg-config
python2
python3
rust-cbindgen
rustc
which
yasm
unzip
] ++ lib.optional gtk3Support wrapGAppsHook;
buildInputs = [
bzip2
dbus
dbus-glib
file
fontconfig
freetype
glib
gtk2
icu
jemalloc
libGL
libGLU
libevent
libjpeg
libnotify
libpng
libstartup_notification
libvpx
libwebp
nspr
nss_3_53
pango
perl
sqlite
xorg.libX11
xorg.libXScrnSaver
xorg.libXcursor
xorg.libXext
xorg.libXft
xorg.libXi
xorg.libXrender
xorg.libXt
xorg.pixman
xorg.xorgproto
xorg.libXdamage
zip
zlib
] ++ lib.optional alsaSupport alsa-lib
++ lib.optional gtk3Support gtk3
++ lib.optional pulseaudioSupport libpulseaudio
++ lib.optionals waylandSupport [ libxkbcommon libdrm ];
NIX_CFLAGS_COMPILE =[
"-I${glib.dev}/include/gio-unix-2.0"
"-I${nss_3_53.dev}/include/nss"
];
patches = [
./no-buildconfig.patch
];
postPatch = ''
rm -rf obj-x86_64-pc-linux-gnu
'';
hardeningDisable = [ "format" ];
preConfigure = ''
# remove distributed configuration files
rm -f configure
rm -f js/src/configure
rm -f .mozconfig*
configureScript="$(realpath ./mach) configure"
# AS=as in the environment causes build failure https://bugzilla.mozilla.org/show_bug.cgi?id=1497286
unset AS
export MOZCONFIG=$(pwd)/mozconfig
# Set C flags for Rust's bindgen program. Unlike ordinary C
# compilation, bindgen does not invoke $CC directly. Instead it
# uses LLVM's libclang. To make sure all necessary flags are
# included we need to look in a few places.
# TODO: generalize this process for other use-cases.
BINDGEN_CFLAGS="$(< ${stdenv.cc}/nix-support/libc-crt1-cflags) \
$(< ${stdenv.cc}/nix-support/libc-cflags) \
$(< ${stdenv.cc}/nix-support/cc-cflags) \
$(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \
${
lib.optionalString stdenv.cc.isClang
"-idirafter ${stdenv.cc.cc}/lib/clang/${
lib.getVersion stdenv.cc.cc
}/include"
} \
${
lib.optionalString stdenv.cc.isGNU
"-isystem ${stdenv.cc.cc}/include/c++/${
lib.getVersion stdenv.cc.cc
} -isystem ${stdenv.cc.cc}/include/c++/${
lib.getVersion stdenv.cc.cc
}/${stdenv.hostPlatform.config}"
} \
$NIX_CFLAGS_COMPILE"
echo "ac_add_options BINDGEN_CFLAGS='$BINDGEN_CFLAGS'" >> $MOZCONFIG
'';
configureFlags = let
toolkitSlug = if gtk3Support then
"3${lib.optionalString waylandSupport "-wayland"}"
else
"2";
toolkitValue = "cairo-gtk${toolkitSlug}";
in [
"--enable-application=comm/mail"
"--with-system-icu"
"--with-system-jpeg"
"--with-system-libevent"
"--with-system-nspr"
"--with-system-nss"
"--with-system-png" # needs APNG support
"--with-system-zlib"
"--with-system-webp"
"--with-system-libvpx"
"--enable-rust-simd"
"--enable-crashreporter"
"--enable-default-toolkit=${toolkitValue}"
"--enable-js-shell"
"--enable-necko-wifi"
"--enable-system-ffi"
"--enable-system-pixman"
"--disable-tests"
"--disable-updater"
"--enable-jemalloc"
] ++ (if debugBuild then [
"--enable-debug"
"--enable-profiling"
] else [
"--disable-debug"
"--enable-release"
"--disable-debug-symbols"
"--enable-optimize"
"--enable-strip"
]) ++ lib.optionals (!stdenv.hostPlatform.isi686) [
# on i686-linux: --with-libclang-path is not available in this configuration
"--with-libclang-path=${llvmPackages.libclang.lib}/lib"
"--with-clang-path=${llvmPackages.clang}/bin/clang"
] ++ lib.optional alsaSupport "--enable-alsa"
++ lib.optional calendarSupport "--enable-calendar"
++ lib.optional enableOfficialBranding "--enable-official-branding"
++ lib.optional pulseaudioSupport "--enable-pulseaudio";
enableParallelBuilding = true;
postConfigure = ''
cd obj-*
'';
makeFlags = lib.optionals enableOfficialBranding [
"MOZILLA_OFFICIAL=1"
"BUILD_OFFICIAL=1"
];
doCheck = false;
desktopItems = [
(makeDesktopItem {
categories = lib.concatStringsSep ";" [ "Application" "Network" ];
desktopName = "Thunderbird";
genericName = "Mail Reader";
name = "thunderbird";
exec = "thunderbird %U";
icon = "thunderbird";
mimeType = lib.concatStringsSep ";" [
# Email
"x-scheme-handler/mailto"
"message/rfc822"
# Feeds
"x-scheme-handler/feed"
"application/rss+xml"
"application/x-extension-rss"
# Newsgroups
"x-scheme-handler/news"
"x-scheme-handler/snews"
"x-scheme-handler/nntp"
];
})
];
postInstall = ''
# TODO: Move to a dev output?
rm -rf $out/include $out/lib/thunderbird-devel-* $out/share/idl
install -Dm 444 $out/lib/thunderbird/chrome/icons/default/default256.png $out/share/icons/hicolor/256x256/apps/thunderbird.png
'';
# Note on GPG support:
# Thunderbird's native GPG support does not yet support smartcards.
# The official upstream recommendation is to configure fall back to gnupg
# using the Thunderbird config `mail.openpgp.allow_external_gnupg`
# and GPG keys set up; instructions with pictures at:
# https://anweshadas.in/how-to-use-yubikey-or-any-gpg-smartcard-in-thunderbird-78/
# For that to work out of the box, it requires `gnupg` on PATH and
# `gpgme` in `LD_LIBRARY_PATH`; we do this below.
preFixup = ''
# Needed to find Mozilla runtime
gappsWrapperArgs+=(
--argv0 "$out/bin/thunderbird"
--set MOZ_APP_LAUNCHER thunderbird
# https://github.com/NixOS/nixpkgs/pull/61980
--set SNAP_NAME "thunderbird"
--set MOZ_LEGACY_PROFILES 1
--set MOZ_ALLOW_DOWNGRADE 1
--prefix PATH : "${lib.getBin gnupg}/bin"
--prefix PATH : "${lib.getBin xdg-utils}/bin"
--prefix LD_LIBRARY_PATH : "${lib.getLib gpgme}/lib"
)
'';
# FIXME: The XUL portion of this can probably be removed as soon as we
# package a Thunderbird >=71.0 since XUL shouldn't be anymore (in use)?
postFixup = ''
local xul="$out/lib/thunderbird/libxul.so"
patchelf --set-rpath "${libnotify}/lib:${lib.getLib systemd}/lib:$(patchelf --print-rpath $xul)" $xul
'';
doInstallCheck = true;
installCheckPhase = ''
"$out/bin/thunderbird" --version
'';
disallowedRequisites = [
stdenv.cc
];
passthru.updateScript = import ./../../browsers/firefox/update.nix {
attrPath = "thunderbird-78";
baseUrl = "http://archive.mozilla.org/pub/thunderbird/releases/";
inherit writeScript lib common-updater-scripts xidel coreutils gnused
gnugrep gnupg curl runtimeShell;
};
requiredSystemFeatures = [ "big-parallel" ];
meta = with lib; {
description = "A full-featured e-mail client";
homepage = "https://www.thunderbird.net";
maintainers = with maintainers; [
eelco
lovesegfault
pierron
vcunat
];
platforms = platforms.linux;
license = licenses.mpl20;
};
}

@ -0,0 +1,13 @@
Remove about:buildconfig. If used as-is, it would add unnecessary runtime dependencies.
--- a/comm/mail/base/jar.mn
+++ b/comm/mail/base/jar.mn
@@ -119,9 +119,7 @@
% override chrome://mozapps/content/profile/profileDowngrade.js chrome://messenger/content/profileDowngrade.js
% override chrome://mozapps/content/profile/profileDowngrade.xhtml chrome://messenger/content/profileDowngrade.xhtml
-* content/messenger/buildconfig.html (content/buildconfig.html)
content/messenger/buildconfig.css (content/buildconfig.css)
-% override chrome://global/content/buildconfig.html chrome://messenger/content/buildconfig.html
% override chrome://global/content/buildconfig.css chrome://messenger/content/buildconfig.css
# L10n resources and overrides.

@ -1,37 +0,0 @@
Remove about:buildconfig. If used as-is, it would add unnecessary runtime dependencies.
diff -ru -x '*~' a/docshell/base/nsAboutRedirector.cpp b/docshell/base/nsAboutRedirector.cpp
--- a/docshell/base/nsAboutRedirector.cpp
+++ b/docshell/base/nsAboutRedirector.cpp
@@ -63,8 +63,6 @@
{"about", "chrome://global/content/aboutAbout.html", 0},
{"addons", "chrome://mozapps/content/extensions/extensions.xhtml",
nsIAboutModule::ALLOW_SCRIPT},
- {"buildconfig", "chrome://global/content/buildconfig.html",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT},
{"checkerboard", "chrome://global/content/aboutCheckerboard.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT},
diff -ru -x '*~' a/toolkit/content/jar.mn b/toolkit/content/jar.mn
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -35,7 +35,6 @@
content/global/plugins.js
content/global/browser-child.js
content/global/browser-content.js
-* content/global/buildconfig.html
content/global/buildconfig.css
content/global/contentAreaUtils.js
content/global/datepicker.xhtml
diff -ru -x '*~' a/comm/mail/base/jar.mn b/comm/mail/base/jar.mn
--- a/comm/mail/base/jar.mn
+++ b/comm/mail/base/jar.mn
@@ -119,9 +119,7 @@
% override chrome://mozapps/content/profile/profileDowngrade.js chrome://messenger/content/profileDowngrade.js
% override chrome://mozapps/content/profile/profileDowngrade.xhtml chrome://messenger/content/profileDowngrade.xhtml
-* content/messenger/buildconfig.html (content/buildconfig.html)
content/messenger/buildconfig.css (content/buildconfig.css)
-% override chrome://global/content/buildconfig.html chrome://messenger/content/buildconfig.html
% override chrome://global/content/buildconfig.css chrome://messenger/content/buildconfig.css
# L10n resources and overrides.

@ -0,0 +1,38 @@
{ stdenv, lib, callPackage, fetchurl, fetchpatch, nixosTests }:
let
common = opts: callPackage (import ../../browsers/firefox/common.nix opts) {
webrtcSupport = false;
geolocationSupport = false;
};
in
rec {
thunderbird = common rec {
pname = "thunderbird";
version = "78.13.0";
application = "comm/mail";
binaryName = pname;
src = fetchurl {
url = "mirror://mozilla/thunderbird/releases/${version}/source/thunderbird-${version}.source.tar.xz";
sha512 = "daee9ea9e57bdfce231a35029807f279a06f8790d71efc8998c78eb42d99a93cf98623170947df99202da038f949ba9111a7ff7adbd43c161794deb6791370a0";
};
patches = [
./no-buildconfig-78.patch
];
meta = with lib; {
description = "A full-featured e-mail client";
homepage = "https://thunderbird.net/";
maintainers = with maintainers; [ eelco lovesegfault pierron vcunat ];
platforms = platforms.unix;
badPlatforms = platforms.darwin;
broken = stdenv.buildPlatform.is32bit; # since Firefox 60, build on 32-bit platforms fails with "out of memory".
# not in `badPlatforms` because cross-compilation on 64-bit machine might work.
license = licenses.mpl20;
};
updateScript = callPackage ./update.nix {
attrPath = "thunderbird-78-unwrapped";
};
};
}

@ -0,0 +1,23 @@
{ lib, wrapFirefox, gpgme, gnupg }:
browser:
args:
(wrapFirefox browser ({
libName = "thunderbird";
} // args))
.overrideAttrs (old: {
# Thunderbird's native GPG support does not yet support smartcards.
# The official upstream recommendation is to configure fall back to gnupg
# using the Thunderbird config `mail.openpgp.allow_external_gnupg`
# and GPG keys set up; instructions with pictures at:
# https://anweshadas.in/how-to-use-yubikey-or-any-gpg-smartcard-in-thunderbird-78/
# For that to work out of the box, it requires `gnupg` on PATH and
# `gpgme` in `LD_LIBRARY_PATH`; we do this below.
buildCommand = old.buildCommand + ''
wrapProgram $out/bin/thunderbird \
--prefix LD_LIBRARY_PATH ':' "${lib.makeLibraryPath [ gpgme ]}" \
--prefix PATH ':' "${lib.makeBinPath [ gnupg ]}"
'';
})

@ -27646,17 +27646,20 @@ with pkgs;
thonny = callPackage ../applications/editors/thonny { };
thunderbird = thunderbird-78;
thunderbirdPackages = recurseIntoAttrs (callPackage ../applications/networking/mailreaders/thunderbird/packages.nix {
callPackage = pkgs.newScope {
inherit (rustPackages) cargo rustc;
libpng = libpng_apng;
gnused = gnused_422;
inherit (darwin.apple_sdk.frameworks) CoreMedia ExceptionHandling
Kerberos AVFoundation MediaToolbox
CoreLocation Foundation AddressBook;
inherit (darwin) libobjc;
};
});
thunderbird-78 = callPackage ../applications/networking/mailreaders/thunderbird {
# Using older Rust for workaround:
# https://bugzilla.mozilla.org/show_bug.cgi?id=1663715
inherit (rustPackages_1_45) cargo rustc;
libpng = libpng_apng;
icu = icu67;
libvpx = libvpx_1_8;
gtk3Support = true;
};
thunderbird-unwrapped = thunderbirdPackages.thunderbird;
thunderbird = wrapThunderbird thunderbird-unwrapped { };
thunderbolt = callPackage ../os-specific/linux/thunderbolt {};
@ -28276,6 +28279,8 @@ with pkgs;
wrapFirefox = callPackage ../applications/networking/browsers/firefox/wrapper.nix { };
wrapThunderbird = callPackage ../applications/networking/mailreaders/thunderbird/wrapper.nix { };
wp-cli = callPackage ../development/tools/wp-cli { };
retroArchCores =

@ -104,7 +104,7 @@ let
jobs.nix-info.x86_64-linux
jobs.nix-info-tested.x86_64-linux
# Ensure that X11/GTK are in order.
jobs.thunderbird.x86_64-linux
jobs.thunderbird-unwrapped.x86_64-linux
jobs.cachix.x86_64-linux
/*