1{ pkgs, fetchgit, php }:
2
3let
4 self = with self; {
5 buildPecl = import ../build-support/build-pecl.nix {
6 inherit php;
7 inherit (pkgs) stdenv autoreconfHook fetchurl;
8 };
9 isPhpOlder55 = pkgs.lib.versionOlder php.version "5.5";
10 isPhp7 = pkgs.lib.versionAtLeast php.version "7.0";
11
12 apcu = if isPhp7 then apcu51 else apcu40;
13
14 apcu40 = assert !isPhp7; buildPecl {
15 name = "apcu-4.0.7";
16
17 sha256 = "1mhbz56mbnq7dryf2d64l84lj3fpr5ilmg2424glans3wcg772hp";
18 };
19
20 apcu51 = assert isPhp7; buildPecl {
21 name = "apcu-5.1.2";
22
23 sha256 = "0r5pfbjbmdj46h20jm3iqmy969qd27ajyf0phjhgykv6j0cqjlgd";
24 };
25
26 imagick = if isPhp7 then imagick34 else imagick31;
27
28 imagick31 = assert !isPhp7; buildPecl {
29 name = "imagick-3.1.2";
30 sha256 = "14vclf2pqcgf3w8nzqbdw0b9v30q898344c84jdbw2sa62n6k1sj";
31 configureFlags = "--with-imagick=${pkgs.imagemagick}";
32 buildInputs = [ pkgs.pkgconfig ];
33 };
34
35 imagick34 = buildPecl {
36 name = "imagick-3.4.0RC4";
37 sha256 = "0fdkzdv3r8sm6y1x11kp3rxsimq6zf15xvi0mhn57svmnan4zh0i";
38 configureFlags = "--with-imagick=${pkgs.imagemagick}";
39 buildInputs = [ pkgs.pkgconfig ];
40 };
41
42 # No support for PHP 7 yet
43 memcache = assert !isPhp7; buildPecl {
44 name = "memcache-3.0.8";
45
46 sha256 = "04c35rj0cvq5ygn2jgmyvqcb0k8d03v4k642b6i37zgv7x15pbic";
47
48 configureFlags = "--with-zlib-dir=${pkgs.zlib}";
49 };
50
51 memcached = if isPhp7 then memcachedPhp7 else memcached22;
52
53 memcached22 = assert !isPhp7; buildPecl {
54 name = "memcached-2.2.0";
55
56 sha256 = "0n4z2mp4rvrbmxq079zdsrhjxjkmhz6mzi7mlcipz02cdl7n1f8p";
57
58 configureFlags = [
59 "--with-zlib-dir=${pkgs.zlib}"
60 "--with-libmemcached-dir=${pkgs.libmemcached}"
61 ];
62
63 buildInputs = with pkgs; [ pkgconfig cyrus_sasl ];
64 };
65
66 # Not released yet
67 memcachedPhp7 = assert isPhp7; buildPecl rec {
68 name = "memcached-php7";
69
70 src = fetchgit {
71 url = "https://github.com/php-memcached-dev/php-memcached";
72 rev = "e573a6e8fc815f12153d2afd561fc84f74811e2f";
73 sha256 = "f7acfdae04ef2ef9ece67b6d009aaf6604db64735fc7619f7169929aabb9c58f";
74 };
75
76 configureFlags = [
77 "--with-zlib-dir=${pkgs.zlib}"
78 "--with-libmemcached-dir=${pkgs.libmemcached}"
79 ];
80
81 buildInputs = with pkgs; [ pkgconfig cyrus_sasl ];
82 };
83
84 xdebug = if isPhp7 then xdebug24 else xdebug23;
85
86 xdebug23 = assert !isPhp7; buildPecl {
87 name = "xdebug-2.3.1";
88
89 sha256 = "0k567i6w7cw14m13s7ip0946pvy5ii16cjwjcinnviw9c24na0xm";
90
91 doCheck = true;
92 checkTarget = "test";
93 };
94
95 xdebug24 = buildPecl {
96 name = "xdebug-2.4.0RC3";
97
98 sha256 = "06ppsihw4cl8kxmywvic6wsm4ps9pvsns2vbab9ivrfyp8b6h5dy";
99
100 doCheck = true;
101 checkTarget = "test";
102 };
103
104 # Since PHP 5.5 OPcache is integrated in the core and has to be enabled via --enable-opcache during compilation.
105 zendopcache = assert isPhpOlder55; buildPecl {
106 name = "zendopcache-7.0.3";
107
108 sha256 = "0qpfbkfy4wlnsfq4vc4q5wvaia83l89ky33s08gqrcfp3p1adn88";
109 };
110
111 zmq = if isPhp7 then zmqPhp7 else zmq11;
112
113 zmq11 = assert !isPhp7; buildPecl {
114 name = "zmq-1.1.2";
115
116 sha256 = "0ccz73p8pkda3y9p9qbr3m19m0yrf7k2bvqgbaly3ibgh9bazc69";
117
118 configureFlags = [
119 "--with-zmq=${pkgs.zeromq2}"
120 ];
121
122 buildInputs = [ pkgs.pkgconfig ];
123 };
124
125 # Not released yet
126 zmqPhp7 = assert isPhp7; buildPecl rec {
127 name = "zmq-php7";
128
129 src = fetchgit {
130 url = "https://github.com/mkoppanen/php-zmq";
131 rev = "94d2b87d195f870775b153b42c29f30da049f4db";
132 sha256 = "51a25b1029800d8abe03c5c08c50d6aee941c95c741dc22d2f853052511f4296";
133 };
134
135 configureFlags = [
136 "--with-zmq=${pkgs.zeromq2}"
137 ];
138
139 buildInputs = [ pkgs.pkgconfig ];
140 };
141
142 # No support for PHP 7 and probably never will be
143 xcache = assert !isPhp7; buildPecl rec {
144 name = "xcache-${version}";
145
146 version = "3.2.0";
147
148 src = pkgs.fetchurl {
149 url = "http://xcache.lighttpd.net/pub/Releases/${version}/${name}.tar.bz2";
150 sha256 = "1gbcpw64da9ynjxv70jybwf9y88idm01kb16j87vfagpsp5s64kx";
151 };
152
153 doCheck = true;
154 checkTarget = "test";
155
156 configureFlags = [
157 "--enable-xcache"
158 "--enable-xcache-coverager"
159 "--enable-xcache-optimizer"
160 "--enable-xcache-assembler"
161 "--enable-xcache-encoder"
162 "--enable-xcache-decoder"
163 ];
164
165 buildInputs = [ pkgs.m4 ];
166 };
167
168 #pthreads requires a build of PHP with ZTS (Zend Thread Safety) enabled
169 #--enable-maintainer-zts or --enable-zts on Windows
170 pthreads = if isPhp7 then pthreads31 else pthreads20;
171
172 pthreads20 = assert (pkgs.config.php.zts or false) && (!isPhp7); buildPecl {
173 name = "pthreads-2.0.10";
174 sha256 = "1xlcb1b1g10jd0xhm3c01a06yqpb5qln47pd1k522138324qvpwb";
175 };
176
177 pthreads31 = assert (pkgs.config.php.zts or false) && isPhp7; buildPecl {
178 name = "pthreads-3.1.5";
179 sha256 = "1ziap0py3zrc7qj9lw4nzq6wx1viyj8v9y1babchizzan014x6p5";
180 };
181
182 # No support for PHP 7 yet
183 geoip = assert !isPhp7; buildPecl {
184 name = "geoip-1.1.0";
185 sha256 = "1fcqpsvwba84gqqmwyb5x5xhkazprwkpsnn4sv2gfbsd4svxxil2";
186
187 configureFlags = [ "--with-geoip=${pkgs.geoip}" ];
188
189 buildInputs = [ pkgs.geoip ];
190 };
191
192 redis = if isPhp7 then redisPhp7 else redis22;
193
194 redis22 = buildPecl {
195 name = "redis-2.2.7";
196 sha256 = "00n9dpk9ak0bl35sbcd3msr78sijrxdlb727nhg7f2g7swf37rcm";
197 };
198
199 # Not released yet
200 redisPhp7 = assert isPhp7; buildPecl rec {
201 name = "redis-php7";
202
203 src = fetchgit {
204 url = "https://github.com/phpredis/phpredis";
205 rev = "4a37e47d0256581ce2f7a3b15b5bb932add09f36";
206 sha256 = "ac5894d168e22ae4a770ce252cfbd07d0f9f1a5b48b084c0559b67fe4d3e51cb";
207 };
208 };
209
210 composer = pkgs.stdenv.mkDerivation rec {
211 name = "composer-${version}";
212 version = "1.0.0-alpha11";
213
214 src = pkgs.fetchurl {
215 url = "https://getcomposer.org/download/${version}/composer.phar";
216 sha256 = "1b41ad352p4296c2j7cdq27wp06w28080bjxnjpmw536scb7yd27";
217 };
218
219 phases = [ "installPhase" ];
220 buildInputs = [ pkgs.makeWrapper ];
221
222 installPhase = ''
223 mkdir -p $out/bin
224 install -D $src $out/libexec/composer/composer.phar
225 makeWrapper ${php}/bin/php $out/bin/composer \
226 --add-flags "$out/libexec/composer/composer.phar"
227 '';
228
229 meta = with pkgs.lib; {
230 description = "Dependency Manager for PHP";
231 license = licenses.mit;
232 homepage = https://getcomposer.org/;
233 maintainers = with maintainers; [ globin offline ];
234 };
235 };
236
237 phpcs = pkgs.stdenv.mkDerivation rec {
238 name = "phpcs-${version}";
239 version = "2.3.4";
240
241 src = pkgs.fetchurl {
242 url = "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${version}/phpcs.phar";
243 sha256 = "ce11e02fba30a35a80b691b05be20415eb8b5dea585a4e6646803342b86abb8c";
244 };
245
246 phases = [ "installPhase" ];
247 buildInputs = [ pkgs.makeWrapper ];
248
249 installPhase = ''
250 mkdir -p $out/bin
251 install -D $src $out/libexec/phpcs/phpcs.phar
252 makeWrapper ${php}/bin/php $out/bin/phpcs \
253 --add-flags "$out/libexec/phpcs/phpcs.phar"
254 '';
255
256 meta = with pkgs.lib; {
257 description = "PHP coding standard tool";
258 license = licenses.bsd3;
259 homepage = https://squizlabs.github.io/PHP_CodeSniffer/;
260 maintainers = with maintainers; [ javaguirre ];
261 };
262 };
263}; in self