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
7 , withMySQL ? false, libmysqlclient
8 , withPgSQL ? false, postgresql
9 , withSQLite ? true, sqlite
10 , withLua ? false, lua5_3
13 stdenv.mkDerivation rec {
17 nativeBuildInputs = [ perl pkg-config ];
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;
27 url = "https://dovecot.org/releases/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz";
28 hash = "sha256-LZCheMQpdhEIi/farlSSo7w9WrYyjDoDLrQl0sJJCX4=";
31 enableParallelBuilding = true;
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
51 # We need this for sysconfdir, see remark below.
52 installFlags = [ "DESTDIR=$(out)" ];
55 cp -r $out/$out/* $out
56 rm -rf $out/$(echo "$out" | cut -d "/" -f2)
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
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=";
69 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
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.
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"
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"
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;
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;
121 opensmtpd-interaction = nixosTests.opensmtpd;
122 inherit (nixosTests) dovecot;