1 { stdenv, lib, fetchgit, fetchFromGitHub
2 , gn, ninja, python3, glib, pkg-config, icu
9 # Use update.sh to update all checksums.
12 version = "9.7.106.18";
14 url = "https://chromium.googlesource.com/v8/v8";
16 sha256 = "0cb3w733w1xn6zq9dsr43nx6llcg9hrmb2dkxairarj9c0igpzyh";
19 git_url = "https://chromium.googlesource.com";
21 # This data is from the DEPS file in the root of a V8 checkout.
23 "base/trace_event/common" = fetchgit {
24 url = "${git_url}/chromium/src/base/trace_event/common.git";
25 rev = "7f36dbc19d31e2aad895c60261ca8f726442bfbb";
26 sha256 = "01b2fhbxznqbakxv42ivrzg6w8l7i9yrd9nf72d6p5xx9dm993j4";
29 url = "${git_url}/chromium/src/build.git";
30 rev = "cf325916d58a194a935c26a56fcf6b525d1e2bf4";
31 sha256 = "1ix4h1cpx9bvgln8590xh7lllhsd9w1hd5k9l1gx5yxxrmywd3s4";
33 "third_party/googletest/src" = fetchgit {
34 url = "${git_url}/external/github.com/google/googletest.git";
35 rev = "16f637fbf4ffc3f7a01fa4eceb7906634565242f";
36 sha256 = "11012k3c3mxzdwcw2iparr9lrckafpyhqzclsj26hmfbgbdi0rrh";
38 "third_party/icu" = fetchgit {
39 url = "${git_url}/chromium/deps/icu.git";
40 rev = "eedbaf76e49d28465d9119b10c30b82906e606ff";
41 sha256 = "0mppvx7wf9zlqjsfaa1cf06brh1fjb6nmiib0lhbb9hd55mqjdjj";
43 "third_party/zlib" = fetchgit {
44 url = "${git_url}/chromium/src/third_party/zlib.git";
45 rev = "6da1d53b97c89b07e47714d88cab61f1ce003c68";
46 sha256 = "0v7ylmbwfwv6w6wp29qdf77kjjnfr2xzin08n0v1yvbhs01h5ppy";
48 "third_party/jinja2" = fetchgit {
49 url = "${git_url}/chromium/src/third_party/jinja2.git";
50 rev = "ee69aa00ee8536f61db6a451f3858745cf587de6";
51 sha256 = "1fsnd5h0gisfp8bdsfd81kk5v4mkqf8z368c7qlm1qcwc4ri4x7a";
53 "third_party/markupsafe" = fetchgit {
54 url = "${git_url}/chromium/src/third_party/markupsafe.git";
55 rev = "1b882ef6372b58bfd55a3285f37ed801be9137cd";
56 sha256 = "1jnjidbh03lhfaawimkjxbprmsgz4snr0jl06630dyd41zkdw5kr";
60 # See `gn_version` in DEPS.
62 url = "https://gn.googlesource.com/gn";
63 rev = "8926696a4186279489cc2b8d768533e61bba73d7";
64 sha256 = "1084lnyb0a1khbgjvak05fcx6jy973wqvsf77n0alxjys18sg2yk";
67 myGn = gn.overrideAttrs (oldAttrs: {
74 stdenv.mkDerivation rec {
87 ${lib.concatStringsSep "\n" (
88 lib.mapAttrsToList (n: v: ''
89 mkdir -p $sourceRoot/${n}
90 cp -r ${v}/* $sourceRoot/${n}
96 ${lib.optionalString stdenv.isAarch64 ''
97 substituteInPlace build/toolchain/linux/BUILD.gn \
98 --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
100 ${lib.optionalString stdenv.isDarwin ''
101 substituteInPlace build/config/compiler/compiler.gni \
102 --replace 'strip_absolute_paths_from_debug_symbols = true' \
103 'strip_absolute_paths_from_debug_symbols = false'
104 substituteInPlace build/config/compiler/BUILD.gn \
105 --replace 'current_toolchain == host_toolchain || !use_xcode_clang' \
108 touch build/config/gclient_args.gni
111 llvmCcAndBintools = symlinkJoin { name = "llvmCcAndBintools"; paths = [ stdenv.cc llvmPackages.llvm ]; };
114 "use_custom_libcxx=false"
115 "is_clang=${lib.boolToString stdenv.cc.isClang}"
117 # "use_system_icu=true"
118 "clang_use_chrome_plugins=false"
119 "is_component_build=false"
120 "v8_use_external_startup_data=false"
123 "is_official_build=false"
124 "treat_warnings_as_errors=false"
125 "v8_enable_i18n_support=true"
127 # ''custom_toolchain="//build/toolchain/linux/unbundle:default"''
128 ''host_toolchain="//build/toolchain/linux/unbundle:default"''
129 ''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"''
130 ] ++ lib.optional stdenv.cc.isClang ''clang_base_path="${llvmCcAndBintools}"''
131 ++ lib.optional stdenv.isDarwin ''use_lld=false'';
133 NIX_CFLAGS_COMPILE = "-O2";
134 FORCE_MAC_SDK_MIN = stdenv.targetPlatform.sdkVer or "10.12";
136 nativeBuildInputs = [
141 ] ++ lib.optionals stdenv.isDarwin [
144 python3.pkgs.setuptools
146 buildInputs = [ glib icu ];
148 ninjaFlags = [ ":d8" "v8_monolith" ];
150 enableParallelBuilding = true;
153 install -D d8 $out/bin/d8
154 install -D -m644 obj/libv8_monolith.a $out/lib/libv8.a
155 install -D -m644 icudtl.dat $out/share/v8/icudtl.dat
156 ln -s libv8.a $out/lib/libv8_monolith.a
157 cp -r ../../include $out
159 mkdir -p $out/lib/pkgconfig
160 cat > $out/lib/pkgconfig/v8.pc << EOF
162 Description: V8 JavaScript Engine
164 Libs: -L$out/lib -lv8 -pthread
165 Cflags: -I$out/include
170 description = "Google's open source JavaScript engine";
171 maintainers = with maintainers; [ cstrahan proglodyte matthewbauer ];
172 platforms = platforms.unix;
173 license = licenses.bsd3;