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