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