@@ -0,0 +1,71 @@
1+{ stdenv, fetchzip, makeWrapper, perlPackages,
2+... }:
3+
4+stdenv.mkDerivation rec {
5+ appname = "popfile";
6+ version = "1.1.3";
7+ name = "${appname}-${version}";
8+
9+ src = fetchzip {
10+ url = "http://getpopfile.org/downloads/${appname}-${version}.zip";
11+ sha256 = "0gcib9j7zxk8r2vb5dbdz836djnyfza36vi8215nxcdfx1xc7l63";
12+ stripRoot = false;
13+ };
14+
15+ buildInputs = [ makeWrapper ] ++ (with perlPackages; [
16+ ## These are all taken from the popfile documentation as applicable to Linux
17+ ## http://getpopfile.org/docs/howtos:allplatformsrequireperl
18+ perl
19+ DBI
20+ DBDSQLite
21+ Digest
22+ DigestMD5
23+ HTMLTagset
24+ MIMEBase64 # == MIMEQuotedPrint
25+ TimeDate # == DateParse
26+ HTMLTemplate
27+ # IO::Socket::Socks is not in nixpkgs
28+ # IOSocketSocks
29+ IOSocketSSL
30+ NetSSLeay
31+ SOAPLite
32+ ]);
33+
34+
35+ phases = [ "unpackPhase" "installPhase" "patchPhase" "postInstall" ];
36+
37+ installPhase = ''
38+ mkdir -p $out/bin
39+ # I user `cd` rather than `cp $out/* ...` b/c the * breaks syntax
40+ # highlighting in emacs for me.
41+ cd $src
42+ cp -r * $out/bin
43+ cd $out/bin
44+ chmod +x *.pl
45+ '';
46+
47+ patchPhase = "patchShebangs $out";
48+
49+ postInstall = ''
50+ find $out -name '*.pl' -executable | while read path; do
51+ wrapProgram "$path" \
52+ --prefix PERL5LIB : $PERL5LIB:$out/bin \
53+ --set POPFILE_ROOT $out/bin \
54+ --set POPFILE_USER \$\{POPFILE_USER:-\$HOME/.popfile\} \
55+ --run "test -d \$POPFILE_USER || mkdir -m 0700 -p \$POPFILE_USER"
56+ done
57+ '';
58+
59+ meta = {
60+ description = "An email classification system that automatically sorts messages and fights spam.";
61+ homepage = http://getpopfile.org;
62+ license = stdenv.lib.licenses.gpl2;
63+
64+ # Should work on OS X, but havent tested it.
65+ # Windows support is more complicated.
66+ # http://getpopfile.org/docs/faq:systemrequirements
67+ platforms = stdenv.lib.platforms.linux;
68+ };
69+
70+}
71+