1{
2 stdenv,
3 lib,
4 fetchurl,
5 makeWrapper,
6 nixosTests,
7 buildPerlPackage,
8 coreutils,
9 curl,
10 git,
11 gnumake,
12 highlight,
13 libgit2,
14 libxcrypt,
15 man,
16 openssl,
17 pkg-config,
18 sqlite,
19 xapian,
20 AnyURIEscape,
21 DBDSQLite,
22 DBI,
23 EmailAddressXS,
24 EmailMIME,
25 IOSocketSSL,
26 # FIXME: to be packaged
27 #, IOSocketSocks
28 IPCRun,
29 Inline,
30 InlineC,
31 LinuxInotify2,
32 MailIMAPClient,
33 # FIXME: to be packaged
34 #, NetNetrc
35 # FIXME: to be packaged
36 #, NetNNTP
37 ParseRecDescent,
38 Plack,
39 PlackMiddlewareReverseProxy,
40 PlackTestExternalServer,
41 Xapian,
42 TestSimple13,
43 TimeDate,
44 URI,
45 XMLTreePP,
46}:
47
48let
49
50 skippedTests = [
51 # fatal: Could not make /tmp/pi-search-9188-DGZM/a.git/branches/ writable by group
52 "search"
53 # perl5.32.0-public-inbox> t/eml.t ...................... 1/? Cannot parse parameter '=?ISO-8859-1?Q?=20charset=3D=1BOF?=' at t/eml.t line 270.
54 # perl5.32.0-public-inbox> # Failed test 'got wide character by assuming utf-8'
55 # perl5.32.0-public-inbox> # at t/eml.t line 272.
56 # perl5.32.0-public-inbox> Wide character in print at /nix/store/38vxlxrvg3yji3jms44qn94lxdysbj5j-perl-5.32.0/lib/perl5/5.32.0/Test2/Formatter/TAP.pm line 125.
57 "eml"
58 # Failed test 'Makefile OK'
59 # at t/hl_mod.t line 19.
60 # got: 'makefile'
61 # expected: 'make'
62 "hl_mod"
63 # Hangs on "inbox unlocked on initial fetch, waiting for IDLE".
64 # Fixed in HEAD: 7234e671 ("t/imapd: workaround a Perl 5.36.0 readline regression")
65 "imapd"
66 # Failed test 'clone + index v1 synced ->created_at'
67 # at t/lei-mirror.t line 175.
68 # got: '1638378723'
69 # expected: undef
70 # Failed test 'clone + index v1 synced ->created_at'
71 # at t/lei-mirror.t line 178.
72 # got: '1638378723'
73 # expected: undef
74 # May be due to the use of $ENV{HOME}.
75 "lei-mirror"
76 # Failed test 'child error (pure-Perl)'
77 # at t/spawn.t line 33.
78 # got: '0'
79 # expected: anything else
80 # waiting for child to reap grandchild...
81 "spawn"
82 # Failed to connect to 127.0.0.1
83 "v2mirror"
84 ];
85
86 testConditions = lib.concatMapStringsSep " " (n: "! -name ${lib.escapeShellArg n}.t") skippedTests;
87
88in
89
90buildPerlPackage rec {
91 pname = "public-inbox";
92 version = "1.9.0";
93
94 src = fetchurl {
95 url = "https://public-inbox.org/public-inbox.git/snapshot/public-inbox-${version}.tar.gz";
96 sha256 = "sha256-ENnT2YK7rpODII9TqiEYSCp5mpWOnxskeSuAf8Ilqro=";
97 };
98
99 outputs = [
100 "out"
101 "devdoc"
102 "sa_config"
103 ];
104
105 postConfigure = ''
106 substituteInPlace Makefile --replace 'TEST_FILES = t/*.t' \
107 'TEST_FILES = $(shell find t -name *.t ${testConditions})'
108 substituteInPlace lib/PublicInbox/TestCommon.pm \
109 --replace /bin/cp ${coreutils}/bin/cp
110 '';
111
112 nativeBuildInputs = [ makeWrapper ];
113
114 buildInputs = [
115 AnyURIEscape
116 DBDSQLite
117 DBI
118 EmailAddressXS
119 highlight
120 IOSocketSSL
121 #IOSocketSocks
122 IPCRun
123 Inline
124 InlineC
125 MailIMAPClient
126 #NetNetrc
127 #NetNNTP
128 ParseRecDescent
129 Plack
130 PlackMiddlewareReverseProxy
131 Xapian
132 TimeDate
133 URI
134 libgit2 # For Gcf2
135 man
136 ];
137
138 doCheck = !stdenv.hostPlatform.isDarwin;
139 nativeCheckInputs = [
140 curl
141 git
142 openssl
143 pkg-config
144 sqlite
145 xapian
146 EmailMIME
147 PlackTestExternalServer
148 TestSimple13
149 XMLTreePP
150 ]
151 ++ lib.optionals stdenv.hostPlatform.isLinux [
152 LinuxInotify2
153 ];
154 preCheck = ''
155 perl certs/create-certs.perl
156 export TEST_LEI_ERR_LOUD=1
157 export HOME="$NIX_BUILD_TOP"/home
158 mkdir -p "$HOME"/.cache/public-inbox/inline-c
159 '';
160
161 installTargets = [ "install" ];
162 postInstall = ''
163 for prog in $out/bin/*; do
164 wrapProgram $prog \
165 --set NIX_CFLAGS_COMPILE_${stdenv.cc.suffixSalt} -I${lib.getDev libxcrypt}/include \
166 --prefix PATH : ${
167 lib.makeBinPath [
168 git
169 xapian
170 # for InlineC
171 gnumake
172 stdenv.cc
173 ]
174 }
175 done
176
177 mv sa_config $sa_config
178 '';
179
180 passthru.tests = {
181 nixos-public-inbox = nixosTests.public-inbox;
182 };
183
184 meta = with lib; {
185 homepage = "https://public-inbox.org/";
186 license = licenses.agpl3Plus;
187 maintainers = with maintainers; [
188 julm
189 qyliss
190 ];
191 platforms = platforms.all;
192 };
193}