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