merge names::NamingTable -> names::Names
[hiphop-php.git] / hhvm.nix
blob71fc04579599ddf2ed2ba4288085f8dd274ad6a2
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
14 , freetype
15 , fribidi
16 , gd
17 , gdb
18 , gettext
19 , git
20 , glog
21 , gmp
22 , gperf
23 , gperftools
24 , hostPlatform
25 , icu
26 , imagemagick6
27 , jemalloc
28 , lastModifiedDate
29 , lib
30 , libcap
31 , libdwarf
32 , libedit
33 , libelf
34 , libevent
35 , libgccjit
36 , libkrb5
37 , libmcrypt
38 , libmemcached
39 , libpng
40 , libsodium
41 , libunwind
42 , libvpx
43 , libxml2
44 , libxslt
45 , libzip
46 , linux-pam
47 , lz4
48 , numactl
49 , oniguruma
50 , openldap
51 , openssl
52 , pcre
53 , perl
54 , pkg-config
55 , python3
56 , re2
57 , re2c
58 , rustChannelOf
59 , stdenv
60 , sqlite
61 , tbb
62 , tzdata
63 , unixtools
64 , unzip
65 , uwimap
66 , which
67 , writeTextDir
68 , zlib
69 , zstd
71 let
72   versionParts =
73     builtins.match
74       ''
75         .*
76         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_MAJOR[[:blank:]]+([[:digit:]]+)
77         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_MINOR[[:blank:]]+([[:digit:]]+)
78         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_PATCH[[:blank:]]+([[:digit:]]+)
79         #[[:blank:]]*define[[:blank:]]+HHVM_VERSION_SUFFIX[[:blank:]]+"([^"]*)"
80         .*
81       ''
82       (builtins.readFile ./hphp/runtime/version.h);
83   makeVersion = major: minor: patch: suffix:
84     if suffix == "-dev" then "${major}.${minor}.${patch}-dev${lastModifiedDate}" else "${major}.${minor}.${patch}";
85   rustNightly = rustChannelOf {
86     sha256 = "TpJKRroEs7V2BTo2GFPJlEScYVArFY2MnGpYTxbnSo8=";
87     date = "2022-02-24";
88     channel = "nightly";
89   };
91 stdenv.mkDerivation rec {
92   pname = "hhvm";
93   version = builtins.foldl' lib.trivial.id makeVersion versionParts;
94   src = ./.;
95   nativeBuildInputs =
96     [
97       bison
98       cacert
99       cmake
100       flex
101       pkg-config
102       python3
103       unixtools.getconf
104       which
105     ];
106   buildInputs =
107     [
108       boost
109       brotli
110       bzip2
111       curl
112       double-conversion
113       editline
114       expat
115       fmt
116       freetype
117       fribidi
118       gd
119       gdb
120       gettext
121       git
122       glog
123       gmp
124       gperf
125       gperftools
126       icu
127       imagemagick6
128       jemalloc
129       libdwarf
130       libedit
131       libelf
132       libevent
133       libgccjit
134       libkrb5
135       libmcrypt
136       libmemcached
137       libpng
138       libsodium
139       libunwind
140       libvpx
141       libxml2
142       libxslt
143       libzip
144       lz4
145       oniguruma
146       openldap
147       openssl
148       pcre
149       perl
150       re2
151       re2c
152       sqlite
153       tbb
154       tzdata
155       unzip
156       zlib
157       zstd
158     ]
159     ++ lib.optionals hostPlatform.isLinux [
160       libcap
161       linux-pam
162       numactl
163       uwimap
164     ]
165     ++ lib.optionals hostPlatform.isMacOS [
166       darwin.apple_sdk.frameworks.CoreFoundation
167       darwin.apple_sdk.frameworks.CoreServices
168     ];
170   NIX_CFLAGS_COMPILE =
171     [
172       "-DFOLLY_MOBILE=0"
173     ]
174     ++ lib.optionals hostPlatform.isMacOS [
175       # Workaround for dtoa.0.3.2
176       "-Wno-error=unused-command-line-argument"
177     ];
179   CMAKE_INIT_CACHE =
180     let
181       # Use writeTextDir instead of writeTextFile as a workaround of https://github.com/xtruder/nix-devcontainer/issues/9
182       dir = writeTextDir "init-cache.cmake"
183         ''
184           set(CAN_USE_SYSTEM_ZSTD ON CACHE BOOL "Use system zstd" FORCE)
185           set(HAVE_SYSTEM_TZDATA_PREFIX "${tzdata}/share/zoneinfo" CACHE PATH "The zoneinfo directory" FORCE)
186           set(HAVE_SYSTEM_TZDATA ON CACHE BOOL "Use system zoneinfo" FORCE)
187           set(MYSQL_UNIX_SOCK_ADDR "/run/mysqld/mysqld.sock" CACHE FILEPATH "The MySQL unix socket" FORCE)
188           set(CARGO_EXECUTABLE "${rustNightly.cargo}/bin/cargo" CACHE FILEPATH "The nightly cargo" FORCE)
189           set(RUSTC_EXECUTABLE "${rustNightly.rust}/bin/rustc" CACHE FILEPATH "The nightly rustc" FORCE)
190           ${
191             lib.optionalString hostPlatform.isMacOS ''
192               set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Targeting macOS version" FORCE)
193             ''
194           }
195         '';
196     in
197     dir + "/init-cache.cmake";
199   cmakeFlags = [ "-C" CMAKE_INIT_CACHE ];
201   prePatch = ''
202     patchShebangs .
203   '';
205   preBuild =
206     ''
207       set -e
208       make \
209         -f third-party/proxygen/CMakeFiles/bundled_proxygen.dir/build.make \
210         third-party/proxygen/bundled_proxygen-prefix/src/bundled_proxygen-stamp/bundled_proxygen-patch
211       patchShebangs \
212         third-party/proxygen/bundled_proxygen-prefix/src/bundled_proxygen
213     '';
215   meta = {
216     description = "High-performance JIT compiler for PHP/Hack";
217     platforms = [
218       "x86_64-darwin"
219       "x86_64-linux"
220     ];
221     homepage = "https://hhvm.com";
222     license = [
223       lib.licenses.php301
224       {
225         spdxId = "Zend-2.0";
226         fullName = "Zend License v2.0";
227         url = "https://www.zend.com/sites/zend/files/pdfs/2_00.txt";
228       }
229     ];
230     maintainers = [{
231       email = "hhvm-oss@fb.com";
232       github = "hhvm";
233       githubId = 4553654;
234       name = "HHVM/Hack Open Source";
235     }];
236   };