perlPackages.NetAsyncWebSocket: 0.13 -> 0.14 (#352432)
[NixPkgs.git] / pkgs / servers / mail / dovecot / default.nix
blobebfb9be622c617f17b7e0667325f4b2a33b1d826
2   stdenv,
3   lib,
4   fetchurl,
5   perl,
6   pkg-config,
7   systemd,
8   openssl,
9   bzip2,
10   zlib,
11   lz4,
12   inotify-tools,
13   pam,
14   libcap,
15   coreutils,
16   clucene_core_2,
17   icu,
18   openldap,
19   libsodium,
20   libstemmer,
21   cyrus_sasl,
22   nixosTests,
23   fetchpatch,
24   # Auth modules
25   withMySQL ? false,
26   libmysqlclient,
27   withPgSQL ? false,
28   postgresql,
29   withSQLite ? true,
30   sqlite,
31   withLua ? false,
32   lua5_3,
35 stdenv.mkDerivation rec {
36   pname = "dovecot";
37   version = "2.3.21.1";
39   nativeBuildInputs = [
40     perl
41     pkg-config
42   ];
43   buildInputs =
44     [
45       openssl
46       bzip2
47       zlib
48       lz4
49       clucene_core_2
50       icu
51       openldap
52       libsodium
53       libstemmer
54       cyrus_sasl.dev
55     ]
56     ++ lib.optionals (stdenv.hostPlatform.isLinux) [
57       systemd
58       pam
59       libcap
60       inotify-tools
61     ]
62     ++ lib.optional withMySQL libmysqlclient
63     ++ lib.optional withPgSQL postgresql
64     ++ lib.optional withSQLite sqlite
65     ++ lib.optional withLua lua5_3;
67   src = fetchurl {
68     url = "https://dovecot.org/releases/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz";
69     hash = "sha256-LZCheMQpdhEIi/farlSSo7w9WrYyjDoDLrQl0sJJCX4=";
70   };
72   enableParallelBuilding = true;
74   postPatch =
75     ''
76       sed -i -E \
77         -e 's!/bin/sh\b!${stdenv.shell}!g' \
78         -e 's!([^[:alnum:]/_-])/bin/([[:alnum:]]+)\b!\1${coreutils}/bin/\2!g' \
79         -e 's!([^[:alnum:]/_-])(head|sleep|cat)\b!\1${coreutils}/bin/\2!g' \
80         src/lib-program-client/test-program-client-local.c
82       patchShebangs src/lib-smtp/test-bin/*.sh
83       sed -i -s -E 's!\bcat\b!${coreutils}/bin/cat!g' src/lib-smtp/test-bin/*.sh
85       patchShebangs src/config/settings-get.pl
87       # DES-encrypted passwords are not supported by NixPkgs anymore
88       sed '/test_password_scheme("CRYPT"/d' -i src/auth/test-libpassword.c
89     ''
90     + lib.optionalString stdenv.hostPlatform.isLinux ''
91       export systemdsystemunitdir=$out/etc/systemd/system
92     '';
94   # We need this for sysconfdir, see remark below.
95   installFlags = [ "DESTDIR=$(out)" ];
97   postInstall = ''
98     cp -r $out/$out/* $out
99     rm -rf $out/$(echo "$out" | cut -d "/" -f2)
100   '';
102   patches =
103     [
104       # Make dovecot look for plugins in /etc/dovecot/modules
105       # so we can symlink plugins from several packages there.
106       # The symlinking needs to be done in NixOS.
107       ./2.3.x-module_dir.patch
108       # fix openssl 3.0 compatibility
109       (fetchpatch {
110         url = "https://salsa.debian.org/debian/dovecot/-/raw/debian/1%252.3.19.1+dfsg1-2/debian/patches/Support-openssl-3.0.patch";
111         hash = "sha256-PbBB1jIY3jIC8Js1NY93zkV0gISGUq7Nc67Ul5tN7sw=";
112       })
113     ]
114     ++ lib.optionals stdenv.hostPlatform.isDarwin [
115       # fix timespec calls
116       ./timespec.patch
117     ];
119   configureFlags =
120     [
121       # It will hardcode this for /var/lib/dovecot.
122       # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626211
123       "--localstatedir=/var"
124       # We need this so utilities default to reading /etc/dovecot/dovecot.conf file.
125       "--sysconfdir=/etc"
126       "--with-ldap"
127       "--with-ssl=openssl"
128       "--with-zlib"
129       "--with-bzlib"
130       "--with-lz4"
131       "--with-ldap"
132       "--with-lucene"
133       "--with-icu"
134     ]
135     ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
136       "i_cv_epoll_works=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
137       "i_cv_posix_fallocate_works=${if stdenv.hostPlatform.isDarwin then "no" else "yes"}"
138       "i_cv_inotify_works=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
139       "i_cv_signed_size_t=no"
140       "i_cv_signed_time_t=yes"
141       "i_cv_c99_vsnprintf=yes"
142       "lib_cv_va_copy=yes"
143       "i_cv_mmap_plays_with_write=yes"
144       "i_cv_gmtime_max_time_t=${toString stdenv.hostPlatform.parsed.cpu.bits}"
145       "i_cv_signed_time_t=yes"
146       "i_cv_fd_passing=yes"
147       "lib_cv_va_copy=yes"
148       "lib_cv___va_copy=yes"
149       "lib_cv_va_val_copy=yes"
150     ]
151     ++ lib.optional stdenv.hostPlatform.isLinux "--with-systemd"
152     ++ lib.optional stdenv.hostPlatform.isDarwin "--enable-static"
153     ++ lib.optional withMySQL "--with-mysql"
154     ++ lib.optional withPgSQL "--with-pgsql"
155     ++ lib.optional withSQLite "--with-sqlite"
156     ++ lib.optional withLua "--with-lua";
158   doCheck = !stdenv.hostPlatform.isDarwin;
160   meta = with lib; {
161     homepage = "https://dovecot.org/";
162     description = "Open source IMAP and POP3 email server written with security primarily in mind";
163     license = with licenses; [
164       mit
165       publicDomain
166       lgpl21Only
167       bsd3
168       bsdOriginal
169     ];
170     mainProgram = "dovecot";
171     maintainers =
172       with maintainers;
173       [
174         fpletz
175         globin
176       ]
177       ++ teams.helsinki-systems.members;
178     platforms = platforms.unix;
179   };
180   passthru.tests = {
181     opensmtpd-interaction = nixosTests.opensmtpd;
182     inherit (nixosTests) dovecot;
183   };