biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / servers / mail / exim / default.nix
blobb5446f7df19083f5b1e508ad98fa15a8b54e8647
1 { coreutils, db, fetchurl, openssl, pcre2, perl, pkg-config, lib, stdenv
2 , libxcrypt
3 , procps, killall
4 , enableLDAP ? false, openldap
5 , enableMySQL ? false, libmysqlclient, zlib
6 , enablePgSQL ? false, postgresql
7 , enableSqlite ? false, sqlite
8 , enableAuthDovecot ? false, dovecot
9 , enablePAM ? false, pam
10 , enableSPF ? true, libspf2
11 , enableDMARC ? true, opendmarc
12 , enableRedis ? false, hiredis
13 , enableJSON ? false, jansson
14 , enableSRS ? false,
16 let
17   perl' = perl.withPackages (p: with p; [ FileFcntlLock ]);
18 in stdenv.mkDerivation rec {
19   pname = "exim";
20   version = "4.97.1";
22   src = fetchurl {
23     url = "https://ftp.exim.org/pub/exim/exim4/${pname}-${version}.tar.xz";
24     hash = "sha256-vXggV1CaeTWTUIUoWQYm0YXqFgzjLLNL7aJi6Zzv36k=";
25   };
27   enableParallelBuilding = true;
29   nativeBuildInputs = [ pkg-config ];
30   buildInputs = [ coreutils db openssl perl' pcre2 libxcrypt ]
31     ++ lib.optional enableLDAP openldap
32     ++ lib.optionals enableMySQL [ libmysqlclient zlib ]
33     ++ lib.optional enablePgSQL postgresql
34     ++ lib.optionals enableSqlite [ sqlite sqlite.dev zlib ]
35     ++ lib.optional enableAuthDovecot dovecot
36     ++ lib.optional enablePAM pam
37     ++ lib.optional enableSPF libspf2
38     ++ lib.optional enableDMARC opendmarc
39     ++ lib.optional enableRedis hiredis
40     ++ lib.optional enableJSON jansson;
42   configurePhase = ''
43     runHook preConfigure
45     sed '
46       s:^\(BIN_DIRECTORY\)=.*:\1='"$out"'/bin:
47       s:^\(CONFIGURE_FILE\)=.*:\1=/etc/exim.conf:
48       s:^\(EXIM_USER\)=.*:\1=ref\:nobody:
49       s:^\(SPOOL_DIRECTORY\)=.*:\1=/exim-homeless-shelter:
50       s:^# \(TRANSPORT_LMTP\)=.*:\1=yes:
51       s:^# \(SUPPORT_MAILDIR\)=.*:\1=yes:
52       s:^EXIM_MONITOR=.*$:# &:
53       s:^\(FIXED_NEVER_USERS\)=root$:\1=0:
54       s:^# \(WITH_CONTENT_SCAN\)=.*:\1=yes:
55       s:^# \(AUTH_PLAINTEXT\)=.*:\1=yes:
56       s:^# \(USE_OPENSSL\)=.*:\1=yes:
57       s:^# \(USE_OPENSSL_PC=openssl\)$:\1:
58       s:^# \(LOG_FILE_PATH=syslog\)$:\1:
59       s:^# \(HAVE_IPV6=yes\)$:\1:
60       s:^# \(CHOWN_COMMAND\)=.*:\1=${coreutils}/bin/chown:
61       s:^# \(CHGRP_COMMAND\)=.*:\1=${coreutils}/bin/chgrp:
62       s:^# \(CHMOD_COMMAND\)=.*:\1=${coreutils}/bin/chmod:
63       s:^# \(MV_COMMAND\)=.*:\1=${coreutils}/bin/mv:
64       s:^# \(RM_COMMAND\)=.*:\1=${coreutils}/bin/rm:
65       s:^# \(TOUCH_COMMAND\)=.*:\1=${coreutils}/bin/touch:
66       s:^# \(PERL_COMMAND\)=.*:\1=${perl'}/bin/perl:
67       s:^# \(LOOKUP_DSEARCH=yes\)$:\1:
68       ${lib.optionalString enableLDAP ''
69         s:^# \(LDAP_LIB_TYPE=OPENLDAP2\)$:\1:
70         s:^# \(LOOKUP_LDAP=yes\)$:\1:
71         s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -lldap -llber:
72         s:^# \(LOOKUP_LIBS\)=.*:\1=-lldap -llber:
73       ''}
74       ${lib.optionalString enableMySQL ''
75         s:^# \(LOOKUP_MYSQL=yes\)$:\1:
76         s:^# \(LOOKUP_MYSQL_PC=libmysqlclient\)$:\1:
77         s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -lmysqlclient -L${libmysqlclient}/lib/mysql -lssl -lm -lpthread -lz:
78         s:^# \(LOOKUP_LIBS\)=.*:\1=-lmysqlclient -L${libmysqlclient}/lib/mysql -lssl -lm -lpthread -lz:
79         s:^# \(LOOKUP_INCLUDE\)=.*:\1=-I${libmysqlclient.dev}/include/mysql/:
80       ''}
81       ${lib.optionalString enablePgSQL ''
82         s:^# \(LOOKUP_PGSQL=yes\)$:\1:
83         s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -lpq -L${postgresql.lib}/lib:
84         s:^# \(LOOKUP_LIBS\)=.*:\1=-lpq -L${postgresql.lib}/lib:
85         s:^# \(LOOKUP_INCLUDE\)=.*:\1=-I${postgresql}/include:
86       ''}
87       ${lib.optionalString enableSqlite ''
88         s:^# \(LOOKUP_SQLITE=yes\)$:\1:
89         s:^# \(LOOKUP_SQLITE_PC=sqlite3\)$:\1:
90         s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -lsqlite3 -L${sqlite}/lib:
91         s:^# \(LOOKUP_LIBS\)=.*:\1=-lsqlite3 -L${sqlite}/lib -lssl -lm -lpthread -lz:
92         s:^# \(LOOKUP_INCLUDE\)=.*:\1=-I${sqlite.dev}/include:
93       ''}
94       ${lib.optionalString enableAuthDovecot ''
95         s:^# \(AUTH_DOVECOT\)=.*:\1=yes:
96       ''}
97       ${lib.optionalString enableSRS ''
98         s:^# \(SUPPORT_SRS\)=.*:\1=yes:
99       ''}
100       ${lib.optionalString enablePAM ''
101         s:^# \(SUPPORT_PAM\)=.*:\1=yes:
102         s:^\(EXTRALIBS_EXIM\)=\(.*\):\1=\2 -lpam:
103         s:^# \(EXTRALIBS_EXIM\)=.*:\1=-lpam:
104       ''}
105       ${lib.optionalString enableSPF ''
106         s:^# \(SUPPORT_SPF\)=.*:\1=yes:
107         s:^# \(LDFLAGS += -lspf2\):\1:
108       ''}
109       ${lib.optionalString enableDMARC ''
110         s:^# \(SUPPORT_DMARC\)=.*:\1=yes:
111         s:^# \(LDFLAGS += -lopendmarc\):\1:
112       ''}
113       ${lib.optionalString enableRedis ''
114         s:^# \(LOOKUP_REDIS=yes\)$:\1:
115         s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -lhiredis -L${hiredis}/lib/hiredis:
116         s:^# \(LOOKUP_LIBS\)=.*:\1=-lhiredis -L${hiredis}/lib/hiredis:
117         s:^\(LOOKUP_INCLUDE\)=\(.*\):\1=\2 -I${hiredis}/include/hiredis/:
118         s:^# \(LOOKUP_INCLUDE\)=.*:\1=-I${hiredis}/include/hiredis/:
119       ''}
120       ${lib.optionalString enableJSON ''
121         s:^# \(LOOKUP_JSON=yes\)$:\1:
122         s:^\(LOOKUP_LIBS\)=\(.*\):\1=\2 -ljansson -L${jansson}/lib:
123         s:^# \(LOOKUP_LIBS\)=.*:\1=-ljansson -L${jansson}/lib:
124         s:^\(LOOKUP_INCLUDE\)=\(.*\):\1=\2 -I${jansson}/include:
125         s:^# \(LOOKUP_INCLUDE\)=.*:\1=-I${jansson}/include:
126       ''}
127       #/^\s*#.*/d
128       #/^\s*$/d
129     ' < src/EDITME > Local/Makefile
131     {
132       echo EXIWHAT_PS_CMD=${procps}/bin/ps
133       echo EXIWHAT_MULTIKILL_CMD=${killall}/bin/killall
134     } >> Local/Makefile
136     runHook postConfigure
137   '';
139   installPhase = ''
140     runHook preInstall
142     mkdir -p $out/bin $out/share/man/man8
143     cp doc/exim.8 $out/share/man/man8
145     ( cd build-Linux-*
146       cp exicyclog exim_checkaccess exim_dumpdb exim_lock exim_tidydb \
147         exipick exiqsumm exigrep exim_dbmbuild exim exim_fixdb eximstats \
148         exinext exiqgrep exiwhat \
149         $out/bin )
151     ( cd $out/bin
152       for i in mailq newaliases rmail rsmtp runq sendmail; do
153         ln -s exim $i
154       done )
156     runHook postInstall
157   '';
159   meta = with lib; {
160     homepage = "https://exim.org/";
161     description = "A mail transfer agent (MTA)";
162     license = with licenses; [ gpl2Plus bsd3 ];
163     mainProgram = "exim";
164     platforms = platforms.linux;
165     maintainers = with maintainers; [ tv ] ++ teams.helsinki-systems.members;
166     changelog = "https://github.com/Exim/exim/blob/exim-${version}/doc/doc-txt/ChangeLog";
167   };