nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 fetchpatch,
6 ncurses,
7 which,
8 perl,
9 gdbm,
10 openssl,
11 cyrus_sasl,
12 gnupg,
13 gpgme,
14 libkrb5,
15 zlib,
16 headerCache ? true,
17 sslSupport ? true,
18 saslSupport ? true,
19 smimeSupport ? false,
20 gpgSupport ? false,
21 gpgmeSupport ? true,
22 imapSupport ? true,
23 pop3Support ? true,
24 smtpSupport ? true,
25 withSidebar ? true,
26 gssSupport ? true,
27 writeScript,
28}:
29assert smimeSupport -> sslSupport;
30assert gpgmeSupport -> sslSupport;
31
32stdenv.mkDerivation rec {
33 pname = "mutt";
34 version = "2.2.14";
35 outputs = [
36 "out"
37 "doc"
38 "info"
39 ];
40
41 src = fetchurl {
42 url = "http://ftp.mutt.org/pub/mutt/${pname}-${version}.tar.gz";
43 hash = "sha256-0WL7bUkeOvQ9b2L5Sbfmh7sMfCWE2lLJmpk1SiXeFO8=";
44 };
45
46 patches = [
47 # Avoid build-only references embedding into 'mutt -v' output.
48 ./no-build-only-refs.patch
49 ]
50 ++ lib.optional smimeSupport (fetchpatch {
51 url = "https://salsa.debian.org/mutt-team/mutt/raw/debian/1.10.1-2/debian/patches/misc/smime.rc.patch";
52 sha256 = "0b4i00chvx6zj9pcb06x2jysmrcb2znn831lcy32cgfds6gr3nsi";
53 });
54
55 enableParallelBuilding = true;
56 strictDeps = true;
57
58 nativeBuildInputs = [
59 perl
60 which
61 ];
62
63 buildInputs = [
64 ncurses
65 zlib
66 ]
67 ++ lib.optional headerCache gdbm
68 ++ lib.optional sslSupport openssl
69 ++ lib.optional gssSupport libkrb5
70 ++ lib.optional saslSupport cyrus_sasl;
71
72 configureFlags = [
73 (lib.enableFeature headerCache "hcache")
74 (lib.enableFeature gpgmeSupport "gpgme")
75 (lib.enableFeature imapSupport "imap")
76 (lib.enableFeature smtpSupport "smtp")
77 (lib.enableFeature pop3Support "pop")
78 (lib.enableFeature withSidebar "sidebar")
79 "--with-mailpath="
80
81 # Look in $PATH at runtime, instead of hardcoding /usr/bin/sendmail
82 "ac_cv_path_SENDMAIL=sendmail"
83
84 # This allows calls with "-d N", that output debug info into ~/.muttdebug*
85 "--enable-debug"
86
87 # The next allows building mutt without having anything setgid
88 # set by the installer, and removing the need for the group 'mail'
89 # I set the value 'mailbox' because it is a default in the configure script
90 "--with-homespool=mailbox"
91 ]
92 ++ lib.optional sslSupport "--with-ssl"
93 ++ lib.optional gssSupport "--with-gss"
94 ++ lib.optional saslSupport "--with-sasl"
95 ++ lib.optional gpgmeSupport "--with-gpgme-prefix=${lib.getDev gpgme}";
96
97 postPatch = lib.optionalString (smimeSupport || gpgmeSupport) ''
98 sed -i 's#/usr/bin/openssl#${openssl}/bin/openssl#' smime_keys.pl
99 '';
100
101 postInstall =
102 lib.optionalString smimeSupport ''
103 # S/MIME setup
104 cp contrib/smime.rc $out/etc/smime.rc
105 sed -i 's#openssl#${openssl}/bin/openssl#' $out/etc/smime.rc
106 echo "source $out/etc/smime.rc" >> $out/etc/Muttrc
107 ''
108 + lib.optionalString gpgSupport ''
109 # GnuPG setup
110 cp contrib/gpg.rc $out/etc/gpg.rc
111 sed -i 's#\(command="\)gpg #\1${gnupg}/bin/gpg #' $out/etc/gpg.rc
112 echo "source $out/etc/gpg.rc" >> $out/etc/Muttrc
113 '';
114
115 passthru = {
116 updateScript = writeScript "update-mutt" ''
117 #!/usr/bin/env nix-shell
118 #!nix-shell -i bash -p curl pcre common-updater-scripts
119
120 set -euo pipefail
121
122 # Expect the text in format of "The current stable public release version is 2.2.6."
123 new_version="$(curl -s http://www.mutt.org/download.html |
124 pcregrep -o1 'The current stable public release version is ([0-9.]+).')"
125 update-source-version ${pname} "$new_version"
126 '';
127 };
128
129 meta = with lib; {
130 description = "Small but very powerful text-based mail client";
131 homepage = "http://www.mutt.org";
132 mainProgram = "mutt";
133 license = licenses.gpl2Plus;
134 platforms = platforms.unix;
135 maintainers = with maintainers; [ rnhmjoj ];
136 };
137}