summary refs log tree commit diff
path: root/pkgs/tools/text/popfile/default.nix
blob: 4048093a3958b68873a87853ea314bb38f6ee80c (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
61
62
63
64
65
66
67
68
69
70
71
{ stdenv, fetchzip, makeWrapper, perlPackages,
... }:

stdenv.mkDerivation rec {
  appname = "popfile";
  version = "1.1.3";
  name = "${appname}-${version}";

  src = fetchzip {
    url = "http://getpopfile.org/downloads/${appname}-${version}.zip";
    sha256 = "0gcib9j7zxk8r2vb5dbdz836djnyfza36vi8215nxcdfx1xc7l63";
    stripRoot = false;
  };

  buildInputs = [ makeWrapper ] ++ (with perlPackages; [
    ## These are all taken from the popfile documentation as applicable to Linux
    ## http://getpopfile.org/docs/howtos:allplatformsrequireperl
    perl
    DBI
    DBDSQLite
    Digest
    DigestMD5
    HTMLTagset
    MIMEBase64 # == MIMEQuotedPrint
    TimeDate # == DateParse
    HTMLTemplate
    # IO::Socket::Socks is not in nixpkgs
    # IOSocketSocks 
    IOSocketSSL
    NetSSLeay
    SOAPLite
  ]);


  phases = [ "unpackPhase" "installPhase" "patchPhase" "postInstall" ];

  installPhase = ''
    mkdir -p $out/bin
    # I user `cd` rather than `cp $out/* ...` b/c the * breaks syntax
    # highlighting in emacs for me.
    cd $src
    cp -r * $out/bin
    cd $out/bin
    chmod +x *.pl
  '';

  patchPhase = "patchShebangs $out";

  postInstall = ''
    find $out -name '*.pl' -executable | while read path; do
      wrapProgram "$path" \
        --prefix PERL5LIB : $PERL5LIB:$out/bin \
        --set POPFILE_ROOT $out/bin \
        --set POPFILE_USER \$\{POPFILE_USER:-\$HOME/.popfile\} \
        --run "test -d \$POPFILE_USER || mkdir -m 0700 -p \$POPFILE_USER"
    done
  '';

  meta = {
    description = "An email classification system that automatically sorts messages and fights spam";
    homepage = http://getpopfile.org;
    license = stdenv.lib.licenses.gpl2;

    # Should work on OS X, but havent tested it.
    # Windows support is more complicated.
    # http://getpopfile.org/docs/faq:systemrequirements
    platforms = stdenv.lib.platforms.linux;
  };

}