about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/networking/mailutils/default.nix
blob: 6ed8b2fc4b5b18565b2fa19356fac692bb310c0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{ lib
, stdenv
, fetchurl
, fetchpatch
, autoreconfHook
, dejagnu
, gettext
, gnum4
, pkg-config
, texinfo
, fribidi
, gdbm
, gnutls
, gss
, guile
, libmysqlclient
, mailcap
, nettools
, pam
, readline
, ncurses
, python3
, sasl
, system-sendmail
, libxcrypt
, mkpasswd

, pythonSupport ? true
, guileSupport ? true
}:

stdenv.mkDerivation rec {
  pname = "mailutils";
  version = "3.16";

  src = fetchurl {
    url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
    hash = "sha256-BB0VjTCMA3YYQ4jpyTbPqEGlHNwl1Nt1mEp3Gj+gAsA=";
  };

  separateDebugInfo = true;

  postPatch = ''
    sed -i -e '/chown root:mail/d' \
           -e 's/chmod [24]755/chmod 0755/' \
      */Makefile{.in,.am}
    sed -i 's:/usr/lib/mysql:${libmysqlclient}/lib/mysql:' configure.ac
  '';

  nativeBuildInputs = [
    autoreconfHook
    gettext
    gnum4
    pkg-config
    texinfo
  ];

  buildInputs = [
    fribidi
    gdbm
    gnutls
    gss
    libmysqlclient
    mailcap
    ncurses
    pam
    readline
    sasl
    libxcrypt
  ] ++ lib.optionals stdenv.isLinux [ nettools ]
  ++ lib.optionals pythonSupport [ python3 ]
  ++ lib.optionals guileSupport [ guile ];

  patches = [
    ./fix-build-mb-len-max.patch
    ./path-to-cat.patch
    # Fix cross-compilation
    # https://lists.gnu.org/archive/html/bug-mailutils/2020-11/msg00038.html
    (fetchpatch {
      url = "https://lists.gnu.org/archive/html/bug-mailutils/2020-11/txtiNjqcNpqOk.txt";
      sha256 = "0ghzqb8qx2q8cffbvqzw19mivv7r5f16whplzhm7hdj0j2i6xf6s";
    })
    # https://github.com/NixOS/nixpkgs/issues/223967
    # https://lists.gnu.org/archive/html/bug-mailutils/2023-04/msg00000.html
    ./don-t-use-descrypt-password-in-the-test-suite.patch
  ];

  enableParallelBuilding = true;
  hardeningDisable = [ "format" ];

  configureFlags = [
    "--with-gssapi"
    "--with-gsasl"
    "--with-mysql"
    "--with-path-sendmail=${system-sendmail}/bin/sendmail"
    "--with-mail-rc=/etc/mail.rc"
    "DEFAULT_CUPS_CONFDIR=${mailcap}/etc" # provides mime.types to mimeview
  ] ++ lib.optional (!pythonSupport) "--without-python"
    ++ lib.optional (!guileSupport) "--without-guile";

  nativeCheckInputs = [ dejagnu mkpasswd ];
  doCheck = !stdenv.isDarwin; # ERROR: All 46 tests were run, 46 failed unexpectedly.
  doInstallCheck = false; # fails

  preCheck = ''
    # Disable comsat tests that fail without tty in the sandbox.
    tty -s || echo > comsat/tests/testsuite.at
    # Remove broken macro
    sed -i '/AT_TESTED/d' libmu_scm/tests/testsuite.at
    # Provide libraries for mhn.
    export LD_LIBRARY_PATH=$(pwd)/lib/.libs
  '';

  postCheck = ''
    unset LD_LIBRARY_PATH
  '';

  meta = with lib; {
    description = "Rich and powerful protocol-independent mail framework";

    longDescription = ''
      GNU Mailutils is a rich and powerful protocol-independent mail
      framework.  It contains a series of useful mail libraries, clients, and
      servers.  These are the primary mail utilities for the GNU system.  The
      central library is capable of handling electronic mail in various
      mailbox formats and protocols, both local and remote.  Specifically,
      this project contains a POP3 server, an IMAP4 server, and a Sieve mail
      filter.  It also provides a POSIX `mailx' client, and a collection of
      other handy tools.

      The GNU Mailutils libraries supply an ample set of primitives for
      handling electronic mail in programs written in C, C++, Python or
      Scheme.

      The utilities provided by Mailutils include imap4d and pop3d mail
      servers, mail reporting utility comsatd, mail filtering program sieve,
      and an implementation of MH message handling system.
    '';

    license = with licenses; [
      lgpl3Plus /* libraries */
      gpl3Plus /* tools */
    ];

    maintainers = with maintainers; [ orivej vrthra ];

    homepage = "https://www.gnu.org/software/mailutils/";
    changelog = "https://git.savannah.gnu.org/cgit/mailutils.git/tree/NEWS";

    # Some of the dependencies fail to build on {cyg,dar}win.
    platforms = platforms.gnu ++ platforms.unix;
  };
}