1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 autoreconfHook,
7 dejagnu,
8 gettext,
9 gnum4,
10 pkg-config,
11 texinfo,
12 fribidi,
13 gdbm,
14 gnutls,
15 gss,
16 guile,
17 libmysqlclient,
18 mailcap,
19 net-tools,
20 pam,
21 readline,
22 ncurses,
23 python3,
24 gsasl,
25 system-sendmail,
26 libxcrypt,
27 mkpasswd,
28
29 pythonSupport ? true,
30 guileSupport ? true,
31}:
32
33stdenv.mkDerivation (finalAttrs: {
34 pname = "mailutils";
35 version = "3.19";
36
37 src = fetchurl {
38 url = "mirror://gnu/mailutils/mailutils-${finalAttrs.version}.tar.xz";
39 hash = "sha256-UCMNIANsW4rYyWsNmWF38fEz+6THx+O0YtOe6zCEn0U=";
40 };
41
42 separateDebugInfo = true;
43
44 postPatch = ''
45 sed -i -e '/chown root:mail/d' \
46 -e 's/chmod [24]755/chmod 0755/' \
47 */Makefile{.in,.am}
48 sed -i 's:/usr/lib/mysql:${libmysqlclient}/lib/mysql:' configure.ac
49 '';
50
51 nativeBuildInputs = [
52 autoreconfHook
53 gettext
54 gnum4
55 pkg-config
56 texinfo
57 ];
58
59 buildInputs = [
60 fribidi
61 gdbm
62 gnutls
63 gss
64 libmysqlclient
65 mailcap
66 ncurses
67 pam
68 readline
69 gsasl
70 libxcrypt
71 ]
72 ++ lib.optionals stdenv.hostPlatform.isLinux [ net-tools ]
73 ++ lib.optionals pythonSupport [ python3 ]
74 ++ lib.optionals guileSupport [ guile ];
75
76 patches = [
77 ./fix-build-mb-len-max.patch
78 ./path-to-cat.patch
79 # Fix cross-compilation
80 # https://lists.gnu.org/archive/html/bug-mailutils/2020-11/msg00038.html
81 (fetchpatch {
82 url = "https://lists.gnu.org/archive/html/bug-mailutils/2020-11/txtiNjqcNpqOk.txt";
83 hash = "sha256-2rhuopBANngq/PRCboIr+ewdawr8472cYwiLjtHCHz4=";
84 })
85 # Avoid hardeningDisable = [ "format" ]; - this patch is from the project's master branch and can be removed at the next version
86 (fetchpatch {
87 url = "https://cgit.git.savannah.gnu.org/cgit/mailutils.git/patch/?id=9379ec9e25ae6bdbd3d6f5ef9930ac2176d2efe7";
88 hash = "sha256-00R1DLMDPsvz3R6UgRO1ZvgMNCiHYS3lfjqAC9VD+Y4=";
89 })
90 # https://github.com/NixOS/nixpkgs/issues/223967
91 # https://lists.gnu.org/archive/html/bug-mailutils/2023-04/msg00000.html
92 ./don-t-use-descrypt-password-in-the-test-suite.patch
93 ];
94
95 enableParallelBuilding = true;
96 strictDeps = true;
97
98 configureFlags = [
99 "--sysconfdir=/etc"
100 "--with-gssapi"
101 "--with-gsasl"
102 "--with-mysql"
103 "--with-path-sendmail=${system-sendmail}/bin/sendmail"
104 "--with-mail-rc=/etc/mail.rc"
105 "DEFAULT_CUPS_CONFDIR=${mailcap}/etc" # provides mime.types to mimeview
106 ]
107 ++ lib.optional (!pythonSupport) "--without-python"
108 ++ lib.optional (!guileSupport) "--without-guile";
109
110 nativeCheckInputs = [
111 dejagnu
112 mkpasswd
113 ];
114
115 doCheck = !stdenv.hostPlatform.isDarwin; # ERROR: All 46 tests were run, 46 failed unexpectedly.
116
117 meta = {
118 description = "Rich and powerful protocol-independent mail framework";
119
120 longDescription = ''
121 GNU Mailutils is a rich and powerful protocol-independent mail
122 framework. It contains a series of useful mail libraries, clients, and
123 servers. These are the primary mail utilities for the GNU system. The
124 central library is capable of handling electronic mail in various
125 mailbox formats and protocols, both local and remote. Specifically,
126 this project contains a POP3 server, an IMAP4 server, and a Sieve mail
127 filter. It also provides a POSIX `mailx' client, and a collection of
128 other handy tools.
129
130 The GNU Mailutils libraries supply an ample set of primitives for
131 handling electronic mail in programs written in C, C++, Python or
132 Scheme.
133
134 The utilities provided by Mailutils include imap4d and pop3d mail
135 servers, mail reporting utility comsatd, mail filtering program sieve,
136 and an implementation of MH message handling system.
137 '';
138
139 license = with lib.licenses; [
140 lgpl3Plus # libraries
141 gpl3Plus # tools
142 ];
143
144 maintainers = with lib.maintainers; [ orivej ];
145
146 homepage = "https://www.gnu.org/software/mailutils/";
147 changelog = "https://git.savannah.gnu.org/cgit/mailutils.git/tree/NEWS";
148
149 # Some of the dependencies fail to build on {cyg,dar}win.
150 platforms = lib.platforms.gnu ++ lib.platforms.unix;
151 };
152})