maintainers: remove email for amuckstot30 (#360059)
[NixPkgs.git] / pkgs / servers / mail / dovecot / default.nix
blob7a2c42fad1f9ff1cf2ba3e903528602d965efc8e
1 { stdenv, lib, fetchurl, perl, pkg-config, systemd, openssl
2 , bzip2, zlib, lz4, inotify-tools, pam, libcap, coreutils
3 , clucene_core_2, icu, openldap, libsodium, libstemmer, cyrus_sasl
4 , nixosTests
5 , fetchpatch
6 # Auth modules
7 , withMySQL ? false, libmysqlclient
8 , withPgSQL ? false, postgresql
9 , withSQLite ? true, sqlite
10 , withLua ? false, lua5_3
13 stdenv.mkDerivation rec {
14   pname = "dovecot";
15   version = "2.3.21.1";
17   nativeBuildInputs = [ perl pkg-config ];
18   buildInputs =
19     [ openssl bzip2 zlib lz4 clucene_core_2 icu openldap libsodium libstemmer cyrus_sasl.dev ]
20     ++ lib.optionals (stdenv.hostPlatform.isLinux) [ systemd pam libcap inotify-tools ]
21     ++ lib.optional withMySQL libmysqlclient
22     ++ lib.optional withPgSQL postgresql
23     ++ lib.optional withSQLite sqlite
24     ++ lib.optional withLua lua5_3;
26   src = fetchurl {
27     url = "https://dovecot.org/releases/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz";
28     hash = "sha256-LZCheMQpdhEIi/farlSSo7w9WrYyjDoDLrQl0sJJCX4=";
29   };
31   enableParallelBuilding = true;
33   postPatch = ''
34     sed -i -E \
35       -e 's!/bin/sh\b!${stdenv.shell}!g' \
36       -e 's!([^[:alnum:]/_-])/bin/([[:alnum:]]+)\b!\1${coreutils}/bin/\2!g' \
37       -e 's!([^[:alnum:]/_-])(head|sleep|cat)\b!\1${coreutils}/bin/\2!g' \
38       src/lib-program-client/test-program-client-local.c
40     patchShebangs src/lib-smtp/test-bin/*.sh
41     sed -i -s -E 's!\bcat\b!${coreutils}/bin/cat!g' src/lib-smtp/test-bin/*.sh
43     patchShebangs src/config/settings-get.pl
45     # DES-encrypted passwords are not supported by NixPkgs anymore
46     sed '/test_password_scheme("CRYPT"/d' -i src/auth/test-libpassword.c
47   '' + lib.optionalString stdenv.hostPlatform.isLinux ''
48     export systemdsystemunitdir=$out/etc/systemd/system
49   '';
51   # We need this for sysconfdir, see remark below.
52   installFlags = [ "DESTDIR=$(out)" ];
54   postInstall = ''
55     cp -r $out/$out/* $out
56     rm -rf $out/$(echo "$out" | cut -d "/" -f2)
57   '';
59   patches = [
60     # Make dovecot look for plugins in /etc/dovecot/modules
61     # so we can symlink plugins from several packages there.
62     # The symlinking needs to be done in NixOS.
63     ./2.3.x-module_dir.patch
64     # fix openssl 3.0 compatibility
65     (fetchpatch {
66       url = "https://salsa.debian.org/debian/dovecot/-/raw/debian/1%252.3.19.1+dfsg1-2/debian/patches/Support-openssl-3.0.patch";
67       hash = "sha256-PbBB1jIY3jIC8Js1NY93zkV0gISGUq7Nc67Ul5tN7sw=";
68     })
69   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
70     # fix timespec calls
71     ./timespec.patch
72   ];
74   configureFlags = [
75     # It will hardcode this for /var/lib/dovecot.
76     # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=626211
77     "--localstatedir=/var"
78     # We need this so utilities default to reading /etc/dovecot/dovecot.conf file.
79     "--sysconfdir=/etc"
80     "--with-ldap"
81     "--with-ssl=openssl"
82     "--with-zlib"
83     "--with-bzlib"
84     "--with-lz4"
85     "--with-ldap"
86     "--with-lucene"
87     "--with-icu"
88   ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
89     "i_cv_epoll_works=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
90     "i_cv_posix_fallocate_works=${if stdenv.hostPlatform.isDarwin then "no" else "yes"}"
91     "i_cv_inotify_works=${if stdenv.hostPlatform.isLinux then "yes" else "no"}"
92     "i_cv_signed_size_t=no"
93     "i_cv_signed_time_t=yes"
94     "i_cv_c99_vsnprintf=yes"
95     "lib_cv_va_copy=yes"
96     "i_cv_mmap_plays_with_write=yes"
97     "i_cv_gmtime_max_time_t=${toString stdenv.hostPlatform.parsed.cpu.bits}"
98     "i_cv_signed_time_t=yes"
99     "i_cv_fd_passing=yes"
100     "lib_cv_va_copy=yes"
101     "lib_cv___va_copy=yes"
102     "lib_cv_va_val_copy=yes"
103   ] ++ lib.optional stdenv.hostPlatform.isLinux "--with-systemd"
104     ++ lib.optional stdenv.hostPlatform.isDarwin "--enable-static"
105     ++ lib.optional withMySQL "--with-mysql"
106     ++ lib.optional withPgSQL "--with-pgsql"
107     ++ lib.optional withSQLite "--with-sqlite"
108     ++ lib.optional withLua "--with-lua";
110   doCheck = !stdenv.hostPlatform.isDarwin;
112   meta = with lib; {
113     homepage = "https://dovecot.org/";
114     description = "Open source IMAP and POP3 email server written with security primarily in mind";
115     license = with licenses; [ mit publicDomain lgpl21Only bsd3 bsdOriginal ];
116     mainProgram = "dovecot";
117     maintainers = with maintainers; [ fpletz globin ] ++ teams.helsinki-systems.members;
118     platforms = platforms.unix;
119   };
120   passthru.tests = {
121     opensmtpd-interaction = nixosTests.opensmtpd;
122     inherit (nixosTests) dovecot;
123   };