2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv, lib, fetchurl, makeWrapper, gnused, db, openssl, cyrus_sasl, libnsl
|
2023-01-11 07:51:40 +00:00
|
|
|
, coreutils, findutils, gnugrep, gawk, icu, pcre2, m4
|
2022-04-15 01:41:22 +00:00
|
|
|
, fetchpatch
|
2020-11-12 23:50:31 +00:00
|
|
|
, buildPackages, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
, withLDAP ? true, openldap
|
|
|
|
, withPgSQL ? false, postgresql
|
|
|
|
, withMySQL ? false, libmysqlclient
|
|
|
|
, withSQLite ? false, sqlite
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
ccargs = lib.concatStringsSep " " ([
|
|
|
|
"-DUSE_TLS" "-DUSE_SASL_AUTH" "-DUSE_CYRUS_SASL" "-I${cyrus_sasl.dev}/include/sasl"
|
|
|
|
"-DHAS_DB_BYPASS_MAKEDEFS_CHECK"
|
|
|
|
] ++ lib.optional withPgSQL "-DHAS_PGSQL"
|
2020-11-30 08:33:03 +00:00
|
|
|
++ lib.optionals withMySQL [ "-DHAS_MYSQL" "-I${libmysqlclient.dev}/include/mysql" "-L${libmysqlclient}/lib/mysql" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
++ lib.optional withSQLite "-DHAS_SQLITE"
|
|
|
|
++ lib.optionals withLDAP ["-DHAS_LDAP" "-DUSE_LDAP_SASL"]);
|
|
|
|
auxlibs = lib.concatStringsSep " " ([
|
|
|
|
"-ldb" "-lnsl" "-lresolv" "-lsasl2" "-lcrypto" "-lssl"
|
|
|
|
] ++ lib.optional withPgSQL "-lpq"
|
|
|
|
++ lib.optional withMySQL "-lmysqlclient"
|
|
|
|
++ lib.optional withSQLite "-lsqlite3"
|
|
|
|
++ lib.optional withLDAP "-lldap");
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
pname = "postfix";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "3.9.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2024-04-21 15:54:59 +00:00
|
|
|
url = "https://de.postfix.org/ftpmirror/official/postfix-${version}.tar.gz";
|
|
|
|
hash = "sha256-VvXkIOfCVFWk6WwZtnL4D5oKNftb7MkkfJ49XcxhfzQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper m4 ];
|
2023-01-11 07:51:40 +00:00
|
|
|
buildInputs = [ db openssl cyrus_sasl icu libnsl pcre2 ]
|
2021-08-05 21:33:18 +00:00
|
|
|
++ lib.optional withPgSQL postgresql
|
|
|
|
++ lib.optional withMySQL libmysqlclient
|
|
|
|
++ lib.optional withSQLite sqlite
|
|
|
|
++ lib.optional withLDAP openldap;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
hardeningEnable = [ "pie" ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./postfix-script-shell.patch
|
|
|
|
./postfix-3.0-no-warnings.patch
|
|
|
|
./post-install-script.patch
|
|
|
|
./relative-symlinks.patch
|
2022-04-15 01:41:22 +00:00
|
|
|
|
|
|
|
# glibc 2.34 compat
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://src.fedoraproject.org/rpms/postfix/raw/2f9d42453e67ebc43f786d98262a249037f80a77/f/postfix-3.6.2-glibc-234-build-fix.patch";
|
|
|
|
sha256 = "sha256-xRUL5gaoIt6HagGlhsGwvwrAfYvzMgydsltYMWvl9BI=";
|
|
|
|
})
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
postPatch = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
sed -e 's!bin/postconf!${buildPackages.postfix}/bin/postconf!' -i postfix-install
|
|
|
|
'' + ''
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
|
|
|
postConfigure = ''
|
|
|
|
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
|
|
|
|
|
|
|
|
makeFlagsArray+=(AR=$AR _AR=$AR RANLIB=$RANLIB _RANLIB=$RANLIB)
|
|
|
|
|
|
|
|
make makefiles CCARGS='${ccargs}' AUXLIBS='${auxlibs}'
|
|
|
|
'';
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
NIX_LDFLAGS = lib.optionalString withLDAP "-llber";
|
|
|
|
|
|
|
|
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 ":" ${lib.makeBinPath [ coreutils findutils gnugrep ]}
|
|
|
|
wrapProgram $out/libexec/postfix/postfix-script \
|
|
|
|
--prefix PATH ":" ${lib.makeBinPath [ coreutils findutils gnugrep gawk gnused ]}
|
2023-10-09 19:29:22 +00:00
|
|
|
|
|
|
|
# Avoid dev-only outputs from being retained in final closure.
|
|
|
|
# `makedefs.out` is a documenttation-only file. It should be safe
|
|
|
|
# to store invalid store paths there.
|
|
|
|
sed -e "s|$NIX_STORE/[a-z0-9]\{32\}-|$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-|g" -i $out/etc/postfix/makedefs.out
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) postfix postfix-raise-smtpd-tls-security-level; };
|
|
|
|
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
2020-11-12 23:50:31 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
homepage = "http://www.postfix.org/";
|
2023-10-09 19:29:22 +00:00
|
|
|
changelog = "https://www.postfix.org/announcements/postfix-${version}.html";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "A fast, easy to administer, and secure mail server";
|
|
|
|
license = with licenses; [ ipl10 epl20 ];
|
|
|
|
platforms = platforms.linux;
|
2021-08-05 21:33:18 +00:00
|
|
|
maintainers = with maintainers; [ globin dotlambda lewo ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|