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