diff --git a/nixos/modules/services/mail/postfix.nix b/nixos/modules/services/mail/postfix.nix index bad9d527f9a..404cdf0f564 100644 --- a/nixos/modules/services/mail/postfix.nix +++ b/nixos/modules/services/mail/postfix.nix @@ -27,7 +27,7 @@ let mainCf = '' - compatibility_level = 9999 + compatibility_level = 2 mail_owner = ${user} default_privs = nobody diff --git a/pkgs/servers/mail/postfix/2.11.nix b/pkgs/servers/mail/postfix/2.11.nix new file mode 100644 index 00000000000..7c936bf1244 --- /dev/null +++ b/pkgs/servers/mail/postfix/2.11.nix @@ -0,0 +1,66 @@ +{ stdenv, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl, coreutils +, findutils, gnugrep, gawk +}: + +stdenv.mkDerivation rec { + + name = "postfix-${version}"; + + version = "2.11.5"; + + src = fetchurl { + url = "ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/${name}.tar.gz"; + sha256 = "11riz8ggaa09pi8d6xv2807qp7yjn918mrylfvkfwmvcdlgwck0a"; + }; + + patches = [ + ./postfix-2.11.0.patch + ./postfix-script-shell.patch + ]; + + buildInputs = [ makeWrapper gnused db openssl cyrus_sasl ]; + + preBuild = '' + sed -e '/^PATH=/d' -i postfix-install + + export command_directory=$out/sbin + export config_directory=$out/etc/postfix + export daemon_directory=$out/libexec/postfix + export data_directory=/var/lib/postfix + export html_directory=$out/share/postfix/doc/html + export mailq_path=$out/bin/mailq + export manpage_directory=$out/share/man + export newaliases_path=$out/bin/newaliases + export queue_directory=/var/spool/postfix + export readme_directory=$out/share/postfix/doc + export sendmail_path=$out/bin/sendmail + + make makefiles \ + CCARGS='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${cyrus_sasl}/include/sasl \ + -fPIE -fstack-protector-all --param ssp-buffer-size=4 -O2 -D_FORTIFY_SOURCE=2' \ + AUXLIBS='-ldb -lnsl -lresolv -lsasl2 -lcrypto -lssl -pie -Wl,-z,relro,-z,now' + ''; + + installTargets = [ "non-interactive-package" ]; + + installFlags = [ " install_root=$out " ]; + + postInstall = '' + mkdir -p $out + mv -v ut/$out/* $out/ + sed -e '/^PATH=/d' -i $out/libexec/postfix/post-install + wrapProgram $out/libexec/postfix/post-install \ + --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin + wrapProgram $out/libexec/postfix/postfix-script \ + --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin + ''; + + meta = { + homepage = "http://www.postfix.org/"; + description = "A fast, easy to administer, and secure mail server"; + license = stdenv.lib.licenses.bsdOriginal; + platforms = stdenv.lib.platforms.linux; + maintainers = [ stdenv.lib.maintainers.rickynils ]; + }; + +} diff --git a/pkgs/servers/mail/postfix/3.0.nix b/pkgs/servers/mail/postfix/3.0.nix new file mode 100644 index 00000000000..52327090e44 --- /dev/null +++ b/pkgs/servers/mail/postfix/3.0.nix @@ -0,0 +1,91 @@ +{ stdenv, lib, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl +, coreutils, findutils, gnugrep, gawk, icu, pcre +, withPgSQL ? false, postgresql +, withMySQL ? false, libmysql +, withSQLite ? false, sqlite +}: + +let + ccargs = lib.concatStringsSep " " ([ + "-DUSE_TLS" "-DUSE_SASL_AUTH" "-DUSE_CYRUS_SASL" "-I${cyrus_sasl}/include/sasl" + "-DHAS_DB_BYPASS_MAKEDEFS_CHECK" + "-fPIE" "-fstack-protector-all" "--param" "ssp-buffer-size=4" "-O2" "-D_FORTIFY_SOURCE=2" + ] ++ lib.optional withPgSQL "-DHAS_PGSQL" + ++ lib.optionals withMySQL [ "-DHAS_MYSQL" "-I${libmysql}/include/mysql" ] + ++ lib.optional withSQLite "-DHAS_SQLITE"); + auxlibs = lib.concatStringsSep " " ([ + "-ldb" "-lnsl" "-lresolv" "-lsasl2" "-lcrypto" "-lssl" "-pie" "-Wl,-z,relro,-z,now" + ] ++ lib.optional withPgSQL "-lpq" + ++ lib.optional withMySQL "-lmysqlclient" + ++ lib.optional withSQLite "-lsqlite3"); + +in stdenv.mkDerivation rec { + + name = "postfix-${version}"; + + version = "3.0.3"; + + src = fetchurl { + url = "ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/${name}.tar.gz"; + sha256 = "00mc12k5p1zlrlqcf33vh5zizaqr5ai8q78dwv69smjh6kn4c7j0"; + }; + + buildInputs = [ makeWrapper gnused db openssl cyrus_sasl icu pcre ] + ++ lib.optional withPgSQL postgresql + ++ lib.optional withMySQL libmysql + ++ lib.optional withSQLite sqlite; + + patches = [ + ./postfix-script-shell.patch + ./postfix-3.0-no-warnings.patch + ./post-install-script.patch + ./relative-symlinks.patch + ]; + + preBuild = '' + sed -e '/^PATH=/d' -i postfix-install + sed -e "s|@PACKAGE@|$out|" -i conf/post-install + + # post-install need skip permissions check/set on all symlinks following to /nix/store + sed -e "s|@NIX_STORE@|$NIX_STORE|" -i conf/post-install + + export command_directory=$out/sbin + export config_directory=/etc/postfix + export meta_directory=$out/etc/postfix + export daemon_directory=$out/libexec/postfix + export data_directory=/var/lib/postfix/data + export html_directory=$out/share/postfix/doc/html + export mailq_path=$out/bin/mailq + export manpage_directory=$out/share/man + export newaliases_path=$out/bin/newaliases + export queue_directory=/var/lib/postfix/queue + export readme_directory=$out/share/postfix/doc + export sendmail_path=$out/bin/sendmail + + make makefiles CCARGS='${ccargs}' AUXLIBS='${auxlibs}' + ''; + + installTargets = [ "non-interactive-package" ]; + + installFlags = [ "install_root=installdir" ]; + + postInstall = '' + mkdir -p $out + mv -v installdir/$out/* $out/ + cp -rv installdir/etc $out + sed -e '/^PATH=/d' -i $out/libexec/postfix/post-install + wrapProgram $out/libexec/postfix/post-install \ + --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin + wrapProgram $out/libexec/postfix/postfix-script \ + --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin + ''; + + meta = { + homepage = "http://www.postfix.org/"; + description = "A fast, easy to administer, and secure mail server"; + license = lib.licenses.bsdOriginal; + platforms = lib.platforms.linux; + maintainers = [ lib.maintainers.rickynils ]; + }; + +} diff --git a/pkgs/servers/mail/postfix/db-linux3.patch b/pkgs/servers/mail/postfix/db-linux3.patch new file mode 100644 index 00000000000..c9dd4646798 --- /dev/null +++ b/pkgs/servers/mail/postfix/db-linux3.patch @@ -0,0 +1,39 @@ +diff --git a/makedefs b/makedefs +index b8b98c8..94443c0 100644 +--- a/makedefs ++++ b/makedefs +@@ -341,20 +341,20 @@ EOF + esac + ;; + Linux.3*) SYSTYPE=LINUX3 +- if [ -f /usr/include/db.h ] +- then +- : we are all set +- elif [ -f /usr/include/db/db.h ] +- then +- CCARGS="$CCARGS -I/usr/include/db" +- else +- # On a properly installed system, Postfix builds +- # by including and by linking with -ldb +- echo "No include file found." 1>&2 +- echo "Install the appropriate db*-devel package first." 1>&2 +- echo "See the RELEASE_NOTES file for more information." 1>&2 +- exit 1 +- fi ++ #if [ -f /usr/include/db.h ] ++ #then ++ #: we are all set ++ #elif [ -f /usr/include/db/db.h ] ++ #then ++ #CCARGS="$CCARGS -I/usr/include/db" ++ #else ++ ## On a properly installed system, Postfix builds ++ ## by including and by linking with -ldb ++ #echo "No include file found." 1>&2 ++ #echo "Install the appropriate db*-devel package first." 1>&2 ++ #echo "See the RELEASE_NOTES file for more information." 1>&2 ++ #exit 1 ++ #fi + SYSLIBS="-ldb" + for name in nsl resolv + do diff --git a/pkgs/servers/mail/postfix/default.nix b/pkgs/servers/mail/postfix/default.nix index 52327090e44..838ca7a8d8d 100644 --- a/pkgs/servers/mail/postfix/default.nix +++ b/pkgs/servers/mail/postfix/default.nix @@ -1,91 +1,70 @@ -{ stdenv, lib, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl -, coreutils, findutils, gnugrep, gawk, icu, pcre -, withPgSQL ? false, postgresql -, withMySQL ? false, libmysql -, withSQLite ? false, sqlite +{ stdenv, fetchurl, db, glibc, openssl, cyrus_sasl +, coreutils, findutils, gnused, gnugrep, bison, perl }: -let - ccargs = lib.concatStringsSep " " ([ - "-DUSE_TLS" "-DUSE_SASL_AUTH" "-DUSE_CYRUS_SASL" "-I${cyrus_sasl}/include/sasl" - "-DHAS_DB_BYPASS_MAKEDEFS_CHECK" - "-fPIE" "-fstack-protector-all" "--param" "ssp-buffer-size=4" "-O2" "-D_FORTIFY_SOURCE=2" - ] ++ lib.optional withPgSQL "-DHAS_PGSQL" - ++ lib.optionals withMySQL [ "-DHAS_MYSQL" "-I${libmysql}/include/mysql" ] - ++ lib.optional withSQLite "-DHAS_SQLITE"); - auxlibs = lib.concatStringsSep " " ([ - "-ldb" "-lnsl" "-lresolv" "-lsasl2" "-lcrypto" "-lssl" "-pie" "-Wl,-z,relro,-z,now" - ] ++ lib.optional withPgSQL "-lpq" - ++ lib.optional withMySQL "-lmysqlclient" - ++ lib.optional withSQLite "-lsqlite3"); +assert stdenv.isLinux; -in stdenv.mkDerivation rec { - - name = "postfix-${version}"; - - version = "3.0.3"; +stdenv.mkDerivation rec { + name = "postfix-2.8.12"; src = fetchurl { url = "ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/${name}.tar.gz"; - sha256 = "00mc12k5p1zlrlqcf33vh5zizaqr5ai8q78dwv69smjh6kn4c7j0"; + sha256 = "11z07mjy53l1fnl7k4101yk4ilibgqr1164628mqcbmmr8bh2szl"; }; - buildInputs = [ makeWrapper gnused db openssl cyrus_sasl icu pcre ] - ++ lib.optional withPgSQL postgresql - ++ lib.optional withMySQL libmysql - ++ lib.optional withSQLite sqlite; + buildInputs = [db openssl cyrus_sasl bison perl]; patches = [ + ./postfix-2.2.9-db.patch + ./postfix-2.2.9-lib.patch + ./db-linux3.patch ./postfix-script-shell.patch - ./postfix-3.0-no-warnings.patch - ./post-install-script.patch - ./relative-symlinks.patch ]; + postPatch = '' + sed -i -e s,/usr/bin,/var/run/current-system/sw/bin, \ + -e s,/usr/sbin,/var/run/current-system/sw/bin, \ + -e s,:/sbin,, src/util/sys_defs.h + ''; + preBuild = '' - sed -e '/^PATH=/d' -i postfix-install - sed -e "s|@PACKAGE@|$out|" -i conf/post-install - - # post-install need skip permissions check/set on all symlinks following to /nix/store - sed -e "s|@NIX_STORE@|$NIX_STORE|" -i conf/post-install - - export command_directory=$out/sbin - export config_directory=/etc/postfix - export meta_directory=$out/etc/postfix export daemon_directory=$out/libexec/postfix - export data_directory=/var/lib/postfix/data - export html_directory=$out/share/postfix/doc/html - export mailq_path=$out/bin/mailq - export manpage_directory=$out/share/man - export newaliases_path=$out/bin/newaliases - export queue_directory=/var/lib/postfix/queue - export readme_directory=$out/share/postfix/doc + export command_directory=$out/sbin + export queue_directory=/var/spool/postfix export sendmail_path=$out/bin/sendmail + export mailq_path=$out/bin/mailq + export newaliases_path=$out/bin/newaliases + export html_directory=$out/share/postfix/doc/html + export manpage_directory=$out/share/man + export sample_directory=$out/share/postfix/doc/samples + export readme_directory=$out/share/postfix/doc - make makefiles CCARGS='${ccargs}' AUXLIBS='${auxlibs}' + make makefiles CCARGS='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${cyrus_sasl}/include/sasl -fPIE -fstack-protector-all --param ssp-buffer-size=4 -O2 -D_FORTIFY_SOURCE=2' AUXLIBS='-lssl -lcrypto -lsasl2 -ldb -lnsl -pie -Wl,-z,relro,-z,now' ''; - installTargets = [ "non-interactive-package" ]; + installPhase = '' + sed -e '/^PATH=/d' -i postfix-install + $SHELL postfix-install install_root=out -non-interactive -package - installFlags = [ "install_root=installdir" ]; - - postInstall = '' mkdir -p $out - mv -v installdir/$out/* $out/ - cp -rv installdir/etc $out - sed -e '/^PATH=/d' -i $out/libexec/postfix/post-install - wrapProgram $out/libexec/postfix/post-install \ - --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin - wrapProgram $out/libexec/postfix/postfix-script \ - --prefix PATH ":" ${coreutils}/bin:${findutils}/bin:${gnugrep}/bin:${gawk}/bin:${gnused}/bin + mv -v "out$out/"* $out/ + + mkdir -p $out/share/postfix + mv conf $out/share/postfix/ + mv LICENSE TLS_LICENSE $out/share/postfix/ + + sed -e 's@^PATH=.*@PATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:'$out'/sbin@' -i $out/share/postfix/conf/post-install $out/libexec/postfix/post-install + sed -e '2aPATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:'$out'/sbin' -i $out/share/postfix/conf/postfix-script $out/libexec/postfix/postfix-script + chmod a+x $out/share/postfix/conf/{postfix-script,post-install} ''; + inherit glibc; + meta = { homepage = "http://www.postfix.org/"; - description = "A fast, easy to administer, and secure mail server"; - license = lib.licenses.bsdOriginal; - platforms = lib.platforms.linux; - maintainers = [ lib.maintainers.rickynils ]; + description = "a fast, easy to administer, and secure mail server"; + license = stdenv.lib.licenses.bsdOriginal; + platforms = stdenv.lib.platforms.linux; + maintainers = [ stdenv.lib.maintainers.simons ]; }; - } diff --git a/pkgs/servers/mail/postfix/postfix-2.11.0.patch b/pkgs/servers/mail/postfix/postfix-2.11.0.patch new file mode 100644 index 00000000000..cdc4521c428 --- /dev/null +++ b/pkgs/servers/mail/postfix/postfix-2.11.0.patch @@ -0,0 +1,76 @@ +diff -ruN postfix-2.11.0-orig/makedefs postfix-2.11.0/makedefs +--- postfix-2.11.0-orig/makedefs 2014-01-05 18:18:56.000000000 +0100 ++++ postfix-2.11.0/makedefs 2014-04-24 09:27:58.193869491 +0200 +@@ -290,36 +290,6 @@ + esac + ;; + Linux.2*) SYSTYPE=LINUX2 +- case "$CCARGS" in +- *-DNO_DB*) ;; +- *-DHAS_DB*) ;; +- *) if [ -f /usr/include/db.h ] +- then +- : we are all set +- elif [ -f /usr/include/db/db.h ] +- then +- CCARGS="$CCARGS -I/usr/include/db" +- else +- # No, we're not going to try db1 db2 db3 etc. +- # On a properly installed system, Postfix builds +- # by including and by linking with -ldb +- echo "No include file found." 1>&2 +- echo "Install the appropriate db*-devel package first." 1>&2 +- exit 1 +- fi +- SYSLIBS="-ldb" +- ;; +- esac +- for name in nsl resolv $GDBM_LIBS +- do +- for lib in /usr/lib64 /lib64 /usr/lib /lib +- do +- test -e $lib/lib$name.a -o -e $lib/lib$name.so && { +- SYSLIBS="$SYSLIBS -l$name" +- break +- } +- done +- done + # Kernel 2.4 added IPv6 + case "$RELEASE" in + 2.[0-3].*) CCARGS="$CCARGS -DNO_IPV6";; +@@ -363,35 +333,6 @@ + esac + ;; + Linux.3*) SYSTYPE=LINUX3 +- case "$CCARGS" in +- *-DNO_DB*) ;; +- *-DHAS_DB*) ;; +- *) if [ -f /usr/include/db.h ] +- then +- : we are all set +- elif [ -f /usr/include/db/db.h ] +- then +- CCARGS="$CCARGS -I/usr/include/db" +- else +- # On a properly installed system, Postfix builds +- # by including and by linking with -ldb +- echo "No include file found." 1>&2 +- echo "Install the appropriate db*-devel package first." 1>&2 +- exit 1 +- fi +- SYSLIBS="-ldb" +- ;; +- esac +- for name in nsl resolv +- do +- for lib in /usr/lib64 /lib64 /usr/lib /usr/lib/* /lib /lib/* +- do +- test -e $lib/lib$name.a -o -e $lib/lib$name.so && { +- SYSLIBS="$SYSLIBS -l$name" +- break +- } +- done +- done + ;; + GNU.0*|GNU/kFreeBSD.[567]*) + SYSTYPE=GNU0 diff --git a/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch b/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch new file mode 100644 index 00000000000..65f55ffd8f0 --- /dev/null +++ b/pkgs/servers/mail/postfix/postfix-2.2.9-db.patch @@ -0,0 +1,40 @@ +diff -ruN postfix-2.2.9/makedefs postfix-2.2.9.new/makedefs +--- postfix-2.2.9/makedefs 2006-01-03 21:50:25.000000000 +0000 ++++ postfix-2.2.9.new/makedefs 2006-03-11 00:38:30.000000000 +0000 +@@ -219,21 +219,21 @@ + ;; + Linux.2*) SYSTYPE=LINUX2 + # Postfix no longer needs DB 1.85 compatibility +- if [ -f /usr/include/db.h ] +- then +- : we are all set +- elif [ -f /usr/include/db/db.h ] +- then +- CCARGS="$CCARGS -I/usr/include/db" +- else +- # No, we're not going to try db1 db2 db3 etc. +- # On a properly installed system, Postfix builds +- # by including and by linking with -ldb +- echo "No include file found." 1>&2 +- echo "Install the appropriate db*-devel package first." 1>&2 +- echo "See the RELEASE_NOTES file for more information." 1>&2 +- exit 1 +- fi ++ #if [ -f /usr/include/db.h ] ++ #then ++ #: we are all set ++ #elif [ -f /usr/include/db/db.h ] ++ #then ++ #CCARGS="$CCARGS -I/usr/include/db" ++ #else ++ ## No, we're not going to try db1 db2 db3 etc. ++ ## On a properly installed system, Postfix builds ++ ## by including and by linking with -ldb ++ #echo "No include file found." 1>&2 ++ #echo "Install the appropriate db*-devel package first." 1>&2 ++ #echo "See the RELEASE_NOTES file for more information." 1>&2 ++ #exit 1 ++ #fi + # GDBM locks the DBM .pag file after open. This breaks postmap. + # if [ -f /usr/include/gdbm-ndbm.h ] + # then diff --git a/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch b/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch new file mode 100644 index 00000000000..03dcaa87f23 --- /dev/null +++ b/pkgs/servers/mail/postfix/postfix-2.2.9-lib.patch @@ -0,0 +1,12 @@ +diff -ruN postfix-2.2.9/makedefs postfix-2.2.9.new/makedefs +--- postfix-2.2.9/makedefs 2006-01-03 21:50:25.000000000 +0000 ++++ postfix-2.2.9.new/makedefs 2006-03-11 01:40:30.000000000 +0000 +@@ -247,7 +247,7 @@ + SYSLIBS="-ldb" + for name in nsl resolv $GDBM_LIBS + do +- for lib in /usr/lib64 /lib64 /usr/lib /lib ++ for lib in $glibc/usr/lib64 $glibc/lib64 $glibc/usr/lib $glibc/lib + do + test -e $lib/lib$name.a -o -e $lib/lib$name.so && { + SYSLIBS="$SYSLIBS -l$name" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4f089fd9dde..603e451116c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9709,7 +9709,10 @@ let popa3d = callPackage ../servers/mail/popa3d { }; - postfix = callPackage ../servers/mail/postfix { }; + postfix28 = callPackage ../servers/mail/postfix { }; + postfix211 = callPackage ../servers/mail/postfix/2.11.nix { }; + postfix30 = callPackage ../servers/mail/postfix/3.0.nix { }; + postfix = postfix30; postsrsd = callPackage ../servers/mail/postsrsd { };