1 { stdenv, lib, fetchgit, fetchFromGitHub
2 , gn, ninja, python39, glib, pkg-config, icu
7 # Use update.sh to update all checksums.
10 version = "8.8.278.14";
12 url = "https://chromium.googlesource.com/v8/v8";
14 sha256 = "0w6zldyas9w6p394876ssn3pnr5rjzjy1a5dcsmdkfj51m4rlg8m";
17 git_url = "https://chromium.googlesource.com";
19 # This data is from the DEPS file in the root of a V8 checkout.
21 "base/trace_event/common" = fetchgit {
22 url = "${git_url}/chromium/src/base/trace_event/common.git";
23 rev = "eb94f1c7aa96207f469008f29989a43feb2718f8";
24 sha256 = "14gym38ncc9cysknv3jrql7jvcpjxf2d1dh4m8jgqb967jyzy5cj";
27 url = "${git_url}/chromium/src/build.git";
28 rev = "2101eff1ac4bfd25f2dfa71ad632a600a38c1ed9";
29 sha256 = "0i3xcwzi4pkv4xpgjkbmcpj5h6mji80zqskkx0jx3sx0ji63fylz";
31 "third_party/googletest/src" = fetchgit {
32 url = "${git_url}/external/github.com/google/googletest.git";
33 rev = "4fe018038f87675c083d0cfb6a6b57c274fb1753";
34 sha256 = "1ilm9dmnm2v4y6l1wyfsajsbqv56j29ldfbpd0ykg4q90gpxz201";
36 "third_party/icu" = fetchgit {
37 url = "${git_url}/chromium/deps/icu.git";
38 rev = "c2a4cae149aae7fd30c4cbe3cf1b30df03b386f1";
39 sha256 = "0lgzxf7hmfsgqazs74v5li9ifg8r0jx5m3gxh1mnw33vpwp7qqf4";
41 "third_party/zlib" = fetchgit {
42 url = "${git_url}/chromium/src/third_party/zlib.git";
43 rev = "e84c9a3fd75fdc39055b7ae27d6ec508e50bd39e";
44 sha256 = "03z30djnb3srhd0nvlxvx58sjqm2bvxk7j3vp4fk6h7a0sa2bdpi";
46 "third_party/jinja2" = fetchgit {
47 url = "${git_url}/chromium/src/third_party/jinja2.git";
48 rev = "a82a4944a7f2496639f34a89c9923be5908b80aa";
49 sha256 = "02mkjwkrzhrg16zx97z792l0faz7gc8vga8w10r5y94p98jymnyz";
51 "third_party/markupsafe" = fetchgit {
52 url = "${git_url}/chromium/src/third_party/markupsafe.git";
53 rev = "0944e71f4b2cb9a871bcbe353f95e889b64a611a";
54 sha256 = "052ij8i7nkqchbvzv6ykj929hvfxjbzq7az2l01r0l2gfazhvdb9";
58 # See `gn_version` in DEPS.
60 url = "https://gn.googlesource.com/gn";
61 rev = "53d92014bf94c3893886470a1c7c1289f8818db0";
62 sha256 = "1xcm07qjk6m2czi150fiqqxql067i832adck6zxrishm70c9jbr9";
65 myGn = gn.overrideAttrs (oldAttrs: {
72 stdenv.mkDerivation rec {
85 ${lib.concatStringsSep "\n" (
86 lib.mapAttrsToList (n: v: ''
87 mkdir -p $sourceRoot/${n}
88 cp -r ${v}/* $sourceRoot/${n}
94 ${lib.optionalString stdenv.isAarch64 ''
95 substituteInPlace build/toolchain/linux/BUILD.gn \
96 --replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
98 ${lib.optionalString stdenv.isDarwin ''
99 substituteInPlace build/config/compiler/compiler.gni \
100 --replace 'strip_absolute_paths_from_debug_symbols = true' \
101 'strip_absolute_paths_from_debug_symbols = false'
102 substituteInPlace build/config/compiler/BUILD.gn \
103 --replace 'current_toolchain == host_toolchain || !use_xcode_clang' \
106 echo 'checkout_google_benchmark = false' > build/config/gclient_args.gni
110 "use_custom_libcxx=false"
111 "is_clang=${lib.boolToString stdenv.cc.isClang}"
113 # "use_system_icu=true"
114 "clang_use_chrome_plugins=false"
115 "is_component_build=false"
116 "v8_use_external_startup_data=false"
119 "is_official_build=false"
120 "treat_warnings_as_errors=false"
121 "v8_enable_i18n_support=true"
123 # ''custom_toolchain="//build/toolchain/linux/unbundle:default"''
124 ''host_toolchain="//build/toolchain/linux/unbundle:default"''
125 ''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"''
126 ] ++ lib.optional stdenv.cc.isClang ''clang_base_path="${stdenv.cc}"'';
128 NIX_CFLAGS_COMPILE = "-O2";
129 FORCE_MAC_SDK_MIN = stdenv.targetPlatform.sdkVer or "10.12";
131 nativeBuildInputs = [
136 ] ++ lib.optionals stdenv.isDarwin [
139 python39.pkgs.setuptools
141 buildInputs = [ glib icu ];
143 ninjaFlags = [ ":d8" "v8_monolith" ];
145 enableParallelBuilding = true;
148 install -D d8 $out/bin/d8
149 install -D -m644 obj/libv8_monolith.a $out/lib/libv8.a
150 install -D -m644 icudtl.dat $out/share/v8/icudtl.dat
151 ln -s libv8.a $out/lib/libv8_monolith.a
152 cp -r ../../include $out
154 mkdir -p $out/lib/pkgconfig
155 cat > $out/lib/pkgconfig/v8.pc << EOF
157 Description: V8 JavaScript Engine
159 Libs: -L$out/lib -lv8 -pthread
160 Cflags: -I$out/include
165 description = "Google's open source JavaScript engine";
166 maintainers = with maintainers; [ cstrahan proglodyte matthewbauer ];
167 platforms = platforms.unix;
168 license = licenses.bsd3;