2017-11-09 14:27:25 +00:00
|
|
|
{
|
|
|
|
stdenv,
|
|
|
|
lib,
|
|
|
|
fetchurl,
|
|
|
|
makeWrapper,
|
|
|
|
gnused,
|
|
|
|
db,
|
|
|
|
openssl,
|
|
|
|
cyrus_sasl,
|
|
|
|
libnsl,
|
2022-12-22 11:38:58 +00:00
|
|
|
coreutils,
|
|
|
|
findutils,
|
|
|
|
gnugrep,
|
|
|
|
gawk,
|
|
|
|
icu,
|
|
|
|
pcre2,
|
|
|
|
m4,
|
2021-09-30 18:23:43 +01:00
|
|
|
fetchpatch,
|
2020-08-02 02:46:09 +01:00
|
|
|
buildPackages,
|
|
|
|
nixosTests,
|
2018-10-15 12:56:23 +01:00
|
|
|
withLDAP ? true,
|
|
|
|
openldap,
|
2016-03-11 14:37:50 +00:00
|
|
|
withPgSQL ? false,
|
|
|
|
postgresql,
|
2019-09-22 08:38:09 +01:00
|
|
|
withMySQL ? false,
|
|
|
|
libmysqlclient,
|
2016-03-11 14:37:50 +00:00
|
|
|
withSQLite ? false,
|
|
|
|
sqlite,
|
2010-08-06 11:34:34 +01:00
|
|
|
}:
|
2006-03-10 23:48:34 +00:00
|
|
|
|
2016-03-11 14:37:50 +00:00
|
|
|
let
|
|
|
|
ccargs = lib.concatStringsSep " " (
|
|
|
|
[
|
2016-04-16 17:48:19 +01:00
|
|
|
"-DUSE_TLS"
|
|
|
|
"-DUSE_SASL_AUTH"
|
|
|
|
"-DUSE_CYRUS_SASL"
|
|
|
|
"-I${cyrus_sasl.dev}/include/sasl"
|
2016-03-11 14:37:50 +00:00
|
|
|
"-DHAS_DB_BYPASS_MAKEDEFS_CHECK"
|
|
|
|
]
|
|
|
|
++ lib.optional withPgSQL "-DHAS_PGSQL"
|
2020-11-26 09:56:11 +00:00
|
|
|
++ lib.optionals withMySQL [
|
|
|
|
"-DHAS_MYSQL"
|
|
|
|
"-I${libmysqlclient.dev}/include/mysql"
|
|
|
|
"-L${libmysqlclient}/lib/mysql"
|
|
|
|
]
|
2017-06-06 12:01:06 +01:00
|
|
|
++ lib.optional withSQLite "-DHAS_SQLITE"
|
2018-09-19 10:34:08 +01:00
|
|
|
++ lib.optionals withLDAP [
|
|
|
|
"-DHAS_LDAP"
|
|
|
|
"-DUSE_LDAP_SASL"
|
2024-12-10 19:26:33 +00:00
|
|
|
]
|
2018-09-19 10:34:08 +01:00
|
|
|
);
|
2016-03-11 14:37:50 +00:00
|
|
|
auxlibs = lib.concatStringsSep " " (
|
|
|
|
[
|
2016-03-15 01:44:24 +00:00
|
|
|
"-ldb"
|
|
|
|
"-lnsl"
|
|
|
|
"-lresolv"
|
|
|
|
"-lsasl2"
|
|
|
|
"-lcrypto"
|
|
|
|
"-lssl"
|
2016-03-11 14:37:50 +00:00
|
|
|
]
|
|
|
|
++ lib.optional withPgSQL "-lpq"
|
|
|
|
++ lib.optional withMySQL "-lmysqlclient"
|
2017-06-06 12:01:06 +01:00
|
|
|
++ lib.optional withSQLite "-lsqlite3"
|
|
|
|
++ lib.optional withLDAP "-lldap"
|
|
|
|
);
|
2024-12-10 19:26:33 +00:00
|
|
|
|
2016-03-11 14:37:50 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "postfix";
|
2024-12-05 05:37:14 +00:00
|
|
|
version = "3.9.1";
|
2012-08-28 14:13:21 +01:00
|
|
|
|
2006-03-10 23:48:34 +00:00
|
|
|
src = fetchurl {
|
2024-03-05 19:09:16 +00:00
|
|
|
url = "https://de.postfix.org/ftpmirror/official/postfix-${version}.tar.gz";
|
2024-12-05 05:37:14 +00:00
|
|
|
hash = "sha256-xIiUTrA2JXbRj1+MxLmzKjW8s11xuUfarJdkr0dw9kM=";
|
2006-03-10 23:48:34 +00:00
|
|
|
};
|
|
|
|
|
2018-11-26 15:13:19 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
m4
|
|
|
|
];
|
2022-12-22 11:38:58 +00:00
|
|
|
buildInputs =
|
|
|
|
[
|
|
|
|
db
|
|
|
|
openssl
|
|
|
|
cyrus_sasl
|
|
|
|
icu
|
|
|
|
libnsl
|
|
|
|
pcre2
|
|
|
|
]
|
2021-07-27 08:42:31 +01:00
|
|
|
++ lib.optional withPgSQL postgresql
|
|
|
|
++ lib.optional withMySQL libmysqlclient
|
|
|
|
++ lib.optional withSQLite sqlite
|
|
|
|
++ lib.optional withLDAP openldap;
|
2008-06-30 22:11:07 +01:00
|
|
|
|
2016-02-26 17:38:15 +00:00
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
hardeningEnable = [ "pie" ];
|
2016-02-12 15:29:23 +00:00
|
|
|
|
2015-12-31 09:02:45 +00:00
|
|
|
patches = [
|
|
|
|
./postfix-script-shell.patch
|
2016-03-11 14:37:50 +00:00
|
|
|
./postfix-3.0-no-warnings.patch
|
|
|
|
./post-install-script.patch
|
|
|
|
./relative-symlinks.patch
|
2021-09-30 18:23:43 +01: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=";
|
|
|
|
})
|
2015-12-31 09:02:45 +00:00
|
|
|
];
|
2012-08-28 14:17:06 +01:00
|
|
|
|
2021-01-15 07:07:56 +00:00
|
|
|
postPatch =
|
|
|
|
lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
2018-12-10 21:48:36 +00:00
|
|
|
sed -e 's!bin/postconf!${buildPackages.postfix}/bin/postconf!' -i postfix-install
|
|
|
|
''
|
|
|
|
+ ''
|
2016-03-11 14:37:50 +00:00
|
|
|
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
|
2018-12-10 21:48:36 +00:00
|
|
|
'';
|
2016-03-11 14:37:50 +00:00
|
|
|
|
2018-12-10 21:48:36 +00:00
|
|
|
postConfigure = ''
|
2008-06-13 05:30:57 +01:00
|
|
|
export command_directory=$out/sbin
|
2016-03-11 14:37:50 +00:00
|
|
|
export config_directory=/etc/postfix
|
|
|
|
export meta_directory=$out/etc/postfix
|
|
|
|
export daemon_directory=$out/libexec/postfix
|
|
|
|
export data_directory=/var/lib/postfix/data
|
2008-06-13 05:30:57 +01:00
|
|
|
export html_directory=$out/share/postfix/doc/html
|
2016-03-11 14:37:50 +00:00
|
|
|
export mailq_path=$out/bin/mailq
|
2008-06-13 05:30:57 +01:00
|
|
|
export manpage_directory=$out/share/man
|
2016-03-11 14:37:50 +00:00
|
|
|
export newaliases_path=$out/bin/newaliases
|
|
|
|
export queue_directory=/var/lib/postfix/queue
|
2008-06-13 05:30:57 +01:00
|
|
|
export readme_directory=$out/share/postfix/doc
|
2016-03-11 14:37:50 +00:00
|
|
|
export sendmail_path=$out/bin/sendmail
|
2008-06-30 22:11:07 +01:00
|
|
|
|
2018-12-10 21:48:36 +00:00
|
|
|
makeFlagsArray+=(AR=$AR _AR=$AR RANLIB=$RANLIB _RANLIB=$RANLIB)
|
|
|
|
|
2016-03-11 14:37:50 +00:00
|
|
|
make makefiles CCARGS='${ccargs}' AUXLIBS='${auxlibs}'
|
2008-06-13 05:30:57 +01:00
|
|
|
'';
|
|
|
|
|
2023-11-02 13:48:35 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2019-10-30 11:34:47 +00:00
|
|
|
NIX_LDFLAGS = lib.optionalString withLDAP "-llber";
|
2019-01-06 13:52:11 +00:00
|
|
|
|
2016-03-11 14:37:50 +00:00
|
|
|
installTargets = [ "non-interactive-package" ];
|
2011-11-05 21:14:30 +00:00
|
|
|
|
2016-03-11 14:37:50 +00:00
|
|
|
installFlags = [ "install_root=installdir" ];
|
2012-08-28 14:17:06 +01:00
|
|
|
|
2016-03-11 14:37:50 +00:00
|
|
|
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 \
|
2016-08-22 23:13:49 +01:00
|
|
|
--prefix PATH ":" ${
|
|
|
|
lib.makeBinPath [
|
|
|
|
coreutils
|
|
|
|
findutils
|
|
|
|
gnugrep
|
|
|
|
]
|
|
|
|
}
|
2016-03-11 14:37:50 +00:00
|
|
|
wrapProgram $out/libexec/postfix/postfix-script \
|
2016-08-22 23:13:49 +01:00
|
|
|
--prefix PATH ":" ${
|
|
|
|
lib.makeBinPath [
|
|
|
|
coreutils
|
|
|
|
findutils
|
|
|
|
gnugrep
|
|
|
|
gawk
|
|
|
|
gnused
|
|
|
|
]
|
|
|
|
}
|
2023-09-26 04:28:17 +01: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
|
2012-08-28 14:17:06 +01:00
|
|
|
'';
|
|
|
|
|
2023-01-22 08:32:20 +00:00
|
|
|
passthru = {
|
|
|
|
tests = { inherit (nixosTests) postfix postfix-raise-smtpd-tls-security-level; };
|
|
|
|
|
|
|
|
updateScript = ./update.sh;
|
|
|
|
};
|
2020-08-02 02:46:09 +01:00
|
|
|
|
2019-08-20 18:36:05 +01:00
|
|
|
meta = with lib; {
|
2020-03-15 16:09:15 +00:00
|
|
|
homepage = "http://www.postfix.org/";
|
2023-09-03 04:05:16 +01:00
|
|
|
changelog = "https://www.postfix.org/announcements/postfix-${version}.html";
|
2016-03-11 14:37:50 +00:00
|
|
|
description = "Fast, easy to administer, and secure mail server";
|
2019-08-20 18:36:05 +01:00
|
|
|
license = with licenses; [
|
|
|
|
ipl10
|
|
|
|
epl20
|
|
|
|
];
|
|
|
|
platforms = platforms.linux;
|
2021-07-27 07:54:51 +01:00
|
|
|
maintainers = with maintainers; [
|
|
|
|
globin
|
|
|
|
dotlambda
|
|
|
|
lewo
|
|
|
|
];
|
2012-08-28 14:13:34 +01:00
|
|
|
};
|
2006-03-10 23:48:34 +00:00
|
|
|
}
|