nixpkgs/pkgs/applications/networking/mailreaders/neomutt/default.nix
Maximilian Bosch 991d4bf68c
mutt/neomutt: work around S/MIME issues with application/pgp-encrypted
The original issue can be reproduced when sending with an unpatched
`mutt` or `neomutt` an email with an attachement which as han `.asc`
extension. This will be interpreted as `application/pgp-encrypted` which
experiences special logic, in the end the attachement will contain
"Version: 1"[1][2][3]

Right now, there are the following issues in the {,neo}mutt packages:

* `mutt.override { smimeSupport = true }` fails to build since the
  Debian patch results in a 404. Debian moved their packages to
  `salsa.debian.org`.

  However we can't use a versioned URL for this as Debian only tracks
  the Mutt versions that are available in their releases. The patch
  doesn't touch Mutt's core and is therefore simple to rebase, so
  sticking to the 1.10.2 patch for now should be sufficient.

* The original issue was never fixed in NeoMutt, currently we use the
  S/MIME database from `pkgs.mime-types` which contains the issue with
  `application/pgp-encrypted` as well.

  After some discussion[4] it seems to be the best decision to use the
  `mailcap` database distributed by Fedora[5] which fixes the issue
  rather than `mime-types` v9 from 2012.

[1] https://bugs.archlinux.org/task/43319
[2] https://bugs.gentoo.org/534658
[3] https://github.com/neomutt/neomutt/blob/neomutt-20180716/sendlib.c#L490-L496
[4] https://github.com/NixOS/nixpkgs/pull/50927#issuecomment-441383260
[5] https://pagure.io/mailcap
2018-11-26 01:51:41 +01:00

99 lines
3.0 KiB
Nix

{ stdenv, fetchFromGitHub, gettext, makeWrapper, tcl, which, writeScript
, ncurses, perl , cyrus_sasl, gss, gpgme, kerberos, libidn, libxml2, notmuch, openssl
, lmdb, libxslt, docbook_xsl, docbook_xml_dtd_42, mailcap
}:
let
muttWrapper = writeScript "mutt" ''
#!${stdenv.shell} -eu
echo 'The neomutt project has renamed the main binary from `mutt` to `neomutt`.'
echo ""
echo 'This wrapper is provided for compatibility purposes only. You should start calling `neomutt` instead.'
echo ""
read -p 'Press any key to launch NeoMutt...' -n1 -s
exec neomutt "$@"
'';
in stdenv.mkDerivation rec {
version = "20180716";
name = "neomutt-${version}";
src = fetchFromGitHub {
owner = "neomutt";
repo = "neomutt";
rev = "neomutt-${version}";
sha256 = "0im2kkahkr04q04irvcimfawxi531ld6wrsa92r2m7l10gmijkl8";
};
buildInputs = [
cyrus_sasl gss gpgme kerberos libidn ncurses
notmuch openssl perl lmdb
mailcap
];
nativeBuildInputs = [
docbook_xsl docbook_xml_dtd_42 gettext libxml2 libxslt.bin makeWrapper tcl which
];
enableParallelBuilding = true;
postPatch = ''
substituteInPlace contrib/smime_keys \
--replace /usr/bin/openssl ${openssl}/bin/openssl
for f in doc/*.{xml,xsl}* ; do
substituteInPlace $f \
--replace http://docbook.sourceforge.net/release/xsl/current ${docbook_xsl}/share/xml/docbook-xsl \
--replace http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd ${docbook_xml_dtd_42}/xml/dtd/docbook/docbookx.dtd
done
# allow neomutt to map attachments to their proper mime.types if specified wrongly
# and use a far more comprehensive list than the one shipped with neomutt
substituteInPlace sendlib.c \
--replace /etc/mime.types ${mailcap}/etc/mime.types
# The string conversion tests all fail with the first version of neomutt
# that has tests (20180223) as well as 20180716 so we disable them for now.
# I don't know if that is related to the tests or our build environment.
# Try again with a later release.
sed -i '/rfc2047/d' test/Makefile.autosetup test/main.c
'';
configureFlags = [
"--gpgme"
"--gss"
"--lmdb"
"--notmuch"
"--ssl"
"--sasl"
"--with-homespool=mailbox"
"--with-mailpath="
# Look in $PATH at runtime, instead of hardcoding /usr/bin/sendmail
"ac_cv_path_SENDMAIL=sendmail"
];
# Fix missing libidn in mutt;
# this fix is ugly since it links all binaries in mutt against libidn
# like pgpring, pgpewrap, ...
NIX_LDFLAGS = "-lidn";
postInstall = ''
cp ${muttWrapper} $out/bin/mutt
wrapProgram "$out/bin/neomutt" --prefix PATH : "$out/libexec/neomutt"
'';
doCheck = true;
checkTarget = "test";
meta = with stdenv.lib; {
description = "A small but very powerful text-based mail client";
homepage = http://www.neomutt.org;
license = licenses.gpl2Plus;
maintainers = with maintainers; [ cstrahan erikryb jfrankenau vrthra ];
platforms = platforms.unix;
};
}