summary refs log tree commit diff
path: root/pkgs/servers/mail/postfix/default.nix
blob: 16d9127e5561ca8407eb376dd4c8fe0531e5cde1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ stdenv, fetchurl, db4, glibc, openssl, cyrus_sasl
, coreutils, findutils, gnused, gnugrep, bison, perl
}:

assert stdenv.isLinux;

stdenv.mkDerivation {
  name = "postfix-2.8.6";
  
  src = fetchurl {
    url = ftp://ftp.cs.uu.nl/mirror/postfix/postfix-release/official/postfix-2.8.6.tar.gz;
    sha256 = "1rfsfhna5hy5lc6hkg1zc2862pdc5c1y9z6aiy8rinlmzrfplhlb";
  };

  installTargets = ["non-interactive-package"];
  
  installFlags = [" install_root=$out "];
  
  preInstall = ''
    sed -e '/^PATH=/d' -i postfix-install
  '';
  
  postInstall = ''
    mkdir -p $out
    mv ut/$out/* $out/

    mkdir $out/share/postfix/conf
    cp conf/* $out/share/postfix/conf
    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}
  '';

  preBuild = ''
    export daemon_directory=$out/libexec/postfix
    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='-DUSE_TLS -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I${cyrus_sasl}/include/sasl' AUXLIBS='-lssl -lcrypto -lsasl2 -ldb -lnsl'
  '';

  buildInputs = [db4 openssl cyrus_sasl bison perl];
  
  patches = [ ./postfix-2.2.9-db.patch  ./postfix-2.2.9-lib.patch ./db-linux3.patch ];

  postPatch = ''
    sed -i -e s,/usr/bin,/var/run/current-system/sw/bin, \
      -e s,/usr/sbin,/var/run/current-system/sw/sbin, \
      -e s,:/sbin,, src/util/sys_defs.h
  '';
  
  inherit glibc;
}