On QueryException provide the ability to get the connection back out for reuse
[hiphop-php.git] / hhvm.nix
blob5ea279aa2a54d465fe60b8e9e875066e20c2b010
1 { bison
2 , boost
3 , brotli
4 , bzip2
5 , cacert
6 , cmake
7 , curl
8 , darwin
9 , double-conversion
10 , editline
11 , expat
12 , flex
13 , fmt_8
14 , freetype
15 , fribidi
16 , gcc-unwrapped
17 , gd
18 , gdb
19 , gettext
20 , gflags
21 , git
22 , glog
23 , gmp
24 , gperf
25 , gperftools
26 , hostPlatform
27 , icu
28 , imagemagick6
29 , jemalloc
30 , lastModifiedDate
31 , lib
32 , libcap
33 , libdwarf_20210528
34 , libedit
35 , libelf
36 , libevent
37 , libkrb5
38 , libmcrypt
39 , libmemcached
40 , libpng
41 , libsodium
42 , libunwind
43 , libvpx
44 , libxml2
45 , libxslt
46 , libzip
47 , linux-pam
48 , lz4
49 , numactl
50 , oniguruma
51 , openldap
52 , openssl_1_1
53 , pcre
54 , perl
55 , pkg-config
56 , python3
57 , re2
58 , re2c
59 , rustChannelOf
60 , stdenv
61 , sqlite
62 , tbb
63 , tzdata
64 , unixtools
65 , unzip
66 , uwimap
67 , which
68 , writeTextFile
69 , zlib
70 , zstd
72 let
73   # TODO(https://github.com/NixOS/nixpkgs/pull/193086): Use stdenv.cc.libcxx once it is available
74   isDefaultStdlib =
75     builtins.match ".*-stdlib=\+\+.*" (builtins.readFile "${stdenv.cc}/nix-support/libcxx-ldflags") == null;
76   versionParts =
77     builtins.match
78       ''
79         .*
80         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_MAJOR[[:blank:]]+([[:digit:]]+)
81         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_MINOR[[:blank:]]+([[:digit:]]+)
82         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_PATCH[[:blank:]]+([[:digit:]]+)
83         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_SUFFIX[[:blank:]]+"([^"]*)"
84         .*
85       ''
86       (builtins.readFile ./hphp/runtime/version.h);
87   makeVersion = major: minor: patch: suffix:
88     if suffix == "-dev" then "${major}.${minor}.${patch}-dev${lastModifiedDate}" else "${major}.${minor}.${patch}";
90   rustChannel = rustChannelOf {
92     # When the date attribute changes, sha256 should be updated accordingly.
93     #
94     # 1. Export your diff to GitHub;
95     # 2. Wait for an error message about sha256 mismatch from the GitHub
96     #    Actions;
97     # 3. Copy the new sha256 from the error message and paste it here;
98     # 4. Submit the diff and export the diff to GitHub, again.
99     # 5. Ensure no error message about sha256 mismatch from the GitHub Actions.
100     sha256 = "wVnIzrnpYGqiCBtc3k55tw4VW8YLA3WZY0mSac+2yl0=";
102     date = "2022-08-11";
103     channel = "nightly";
104   };
106 stdenv.mkDerivation rec {
107   rust = rustChannel.rust;
108   pname = "hhvm";
109   version = builtins.foldl' lib.trivial.id makeVersion versionParts;
110   src = ./.;
111   nativeBuildInputs =
112     [
113       bison
114       cacert
115       cmake
116       flex
117       pkg-config
118       python3
119       unixtools.getconf
120       which
121     ] ++ lib.optionals hostPlatform.isMacOS [
122       # `system_cmds` provides `sysctl`, which is used in hphp/test/run.php on macOS
123       darwin.system_cmds
124     ];
125   buildInputs =
126     [
127       (if isDefaultStdlib then boost else boost.override { inherit stdenv; })
128       brotli
129       bzip2
130       (curl.override { openssl = openssl_1_1; })
131       (
132         if isDefaultStdlib then
133           double-conversion
134         else
135           double-conversion.override { inherit stdenv; }
136       )
137       editline
138       expat
139       (if isDefaultStdlib then fmt_8 else fmt_8.override { inherit stdenv; })
140       freetype
141       fribidi
142       # Workaround for https://github.com/NixOS/nixpkgs/issues/192665
143       gcc-unwrapped.lib
144       gd
145       gdb
146       gettext
147       git
148       (
149         if isDefaultStdlib then
150           glog
151         else
152           (glog.override {
153             inherit stdenv;
154             gflags = gflags.override { inherit stdenv; };
155           }).overrideAttrs
156             (finalAttrs: previousAttrs: {
157               # Workaround for https://github.com/google/glog/issues/709
158               doCheck = !stdenv.cc.isClang;
159             })
160       )
161       gmp
162       (if isDefaultStdlib then gperf else gperf.override { inherit stdenv; })
163       (
164         if isDefaultStdlib then
165           gperftools
166         else
167           gperftools.override { inherit stdenv; }
168       )
169       (if isDefaultStdlib then icu else icu.override { inherit stdenv; })
170       imagemagick6
171       jemalloc
172       libdwarf_20210528
173       libedit
174       libelf
175       libevent
176       libkrb5
177       libmcrypt
178       libmemcached
179       libpng
180       libsodium
181       libunwind
182       libvpx
183       libxml2
184       libxslt
185       libzip
186       lz4
187       oniguruma
188       openldap
189       openssl_1_1
190       pcre
191       perl
192       re2
193       re2c
194       sqlite
195       (if isDefaultStdlib then tbb else tbb.override { inherit stdenv; })
196       tzdata
197       unzip
198       zlib
199       zstd
200     ]
201     ++ lib.optionals hostPlatform.isLinux [
202       libcap
203       linux-pam
204       numactl
205       uwimap
206     ]
207     ++ lib.optionals hostPlatform.isMacOS [
208       darwin.apple_sdk.frameworks.CoreFoundation
209       darwin.apple_sdk.frameworks.CoreServices
210     ];
212   NIX_CFLAGS_COMPILE =
213     lib.optionals stdenv.cc.isClang [
214       # Workaround for dtoa.0.3.2
215       "-Wno-error=unused-command-line-argument"
216     ];
218   CMAKE_TOOLCHAIN_FILE = writeTextFile {
219     name = "toolchain.cmake";
220     text = ''
221       set(ENABLE_SYSTEM_LOCALE_ARCHIVE ON CACHE BOOL "Use system locale archive as the default LOCALE_ARCHIVE for nix patched glibc" FORCE)
222       set(CAN_USE_SYSTEM_ZSTD ON CACHE BOOL "Use system zstd" FORCE)
223       set(HAVE_SYSTEM_TZDATA_PREFIX "${tzdata}/share/zoneinfo" CACHE PATH "The zoneinfo directory" FORCE)
224       set(HAVE_SYSTEM_TZDATA ON CACHE BOOL "Use system zoneinfo" FORCE)
225       set(MYSQL_UNIX_SOCK_ADDR "/run/mysqld/mysqld.sock" CACHE FILEPATH "The MySQL unix socket" FORCE)
226       set(CARGO_EXECUTABLE "${rust}/bin/cargo" CACHE FILEPATH "The nightly cargo" FORCE)
227       set(RUSTC_EXECUTABLE "${rust}/bin/rustc" CACHE FILEPATH "The nightly rustc" FORCE)
228       set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Enable verbose output from Makefile builds" FORCE)
229       ${
230         lib.optionalString hostPlatform.isMacOS ''
231           set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Targeting macOS version" FORCE)
232         ''
233       }
234     '';
235   };
237   prePatch = ''
238     patchShebangs .
239   '';
241   preBuild =
242     ''
243       set -e
244       make \
245         -f third-party/proxygen/CMakeFiles/bundled_proxygen.dir/build.make \
246         third-party/proxygen/bundled_proxygen-prefix/src/bundled_proxygen-stamp/bundled_proxygen-patch
247       patchShebangs \
248         third-party/proxygen/bundled_proxygen-prefix/src/bundled_proxygen
249     '';
251   doCheck = true;
253   checkPhase =
254     ''
255       set -e
256       runHook preCheck
257       export HHVM_BIN="$PWD/hphp/hhvm/hhvm"
258       (cd ${./.} && "$HHVM_BIN" hphp/test/run.php quick)
259       runHook postCheck
260     '';
262   meta = {
263     description = "High-performance JIT compiler for PHP/Hack";
264     platforms = [
265       "x86_64-darwin"
266       "x86_64-linux"
267     ];
268     homepage = "https://hhvm.com";
269     license = [
270       lib.licenses.php301
271       {
272         spdxId = "Zend-2.0";
273         fullName = "Zend License v2.0";
274         url = "https://www.zend.com/sites/zend/files/pdfs/2_00.txt";
275       }
276     ];
277     maintainers = [{
278       email = "hhvm-oss@fb.com";
279       github = "hhvm";
280       githubId = 4553654;
281       name = "HHVM/Hack Open Source";
282     }];
283   };