35 stdenv.mkDerivation rec {
56 ++ lib.optionals (stdenv.hostPlatform.isLinux) [
62 ++ lib.optional withMySQL libmysqlclient
63 ++ lib.optional withPgSQL postgresql
64 ++ lib.optional withSQLite sqlite
65 ++ lib.optional withLua lua5_3;
68 url = "https://dovecot.org/releases/${lib.versions.majorMinor version}/${pname}-${version}.tar.gz";
69 hash = "sha256-LZCheMQpdhEIi/farlSSo7w9WrYyjDoDLrQl0sJJCX4=";
72 enableParallelBuilding = true;
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
90 + lib.optionalString stdenv.hostPlatform.isLinux ''
91 export systemdsystemunitdir=$out/etc/systemd/system
94 # We need this for sysconfdir, see remark below.
95 installFlags = [ "DESTDIR=$(out)" ];
98 cp -r $out/$out/* $out
99 rm -rf $out/$(echo "$out" | cut -d "/" -f2)
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
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=";
114 ++ lib.optionals stdenv.hostPlatform.isDarwin [
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.
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"
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"
148 "lib_cv___va_copy=yes"
149 "lib_cv_va_val_copy=yes"
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;
161 homepage = "https://dovecot.org/";
162 description = "Open source IMAP and POP3 email server written with security primarily in mind";
163 license = with licenses; [
170 mainProgram = "dovecot";
177 ++ teams.helsinki-systems.members;
178 platforms = platforms.unix;
181 opensmtpd-interaction = nixosTests.opensmtpd;
182 inherit (nixosTests) dovecot;