Skip to content

Commit 67382c6

Browse files
committed
Drop nixpkgs-oldstable
Lets avoid a whole other nixpkgs source fetch/copy + all of the runtime dependencies that bloat the image (glibc + w/e else). Instead lets just define these packages so we share everything.
1 parent 56e62e7 commit 67382c6

5 files changed

Lines changed: 279 additions & 34 deletions

File tree

flake.lock

Lines changed: 0 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
nix-eval-jobs.url = "github:nix-community/nix-eval-jobs";
2525
nix2container.inputs.nixpkgs.follows = "nixpkgs";
2626
nix2container.url = "github:nlewo/nix2container";
27-
# Pin to a specific nixpkgs version that has compatible v8 and curl versions
28-
# for extensions that require older package versions
29-
nixpkgs-oldstable.url = "github:NixOS/nixpkgs/a76c4553d7e741e17f289224eda135423de0491d";
3027
nixpkgs.url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz";
3128
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
3229
rust-overlay.url = "github:oxalica/rust-overlay";

nix/nixpkgs.nix

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,34 @@
55
{
66
_module.args.pkgs = import inputs.nixpkgs {
77
inherit system;
8-
config.allowUnfree = true;
9-
permittedInsecurePackages = [ "v8-9.7.106.18" ];
8+
config = {
9+
allowUnfree = true;
10+
permittedInsecurePackages = [ "v8-9.7.106.18" ];
11+
};
1012
overlays = [
1113
(import inputs.rust-overlay)
1214
self.overlays.default
13-
(
14-
let
15-
# Provide older versions of packages required by some extensions
16-
oldstable = import inputs.nixpkgs-oldstable {
17-
inherit system;
18-
config.allowUnfree = true;
15+
(final: prev: {
16+
curl_8_6 = prev.curl.overrideAttrs (old: rec {
17+
version = "8.6.0";
18+
src = prev.fetchurl {
19+
urls = [
20+
"https://curl.haxx.se/download/curl-${version}.tar.xz"
21+
"https://github.com/curl/curl/releases/download/curl-${
22+
builtins.replaceStrings [ "." ] [ "_" ] version
23+
}/curl-${version}.tar.xz"
24+
];
25+
hash = "sha256-PM1V2Rr5UWU534BiX4GMc03G8uz5utozx2dl6ZEh2xU=";
1926
};
20-
in
21-
_final: _prev: {
22-
curl_8_6 = oldstable.curl;
23-
v8_oldstable = oldstable.v8;
24-
}
25-
)
27+
configureFlags = builtins.filter (
28+
flag: !builtins.elem flag [
29+
"--with-nghttp3"
30+
"--with-ngtcp2"
31+
]
32+
) old.configureFlags;
33+
});
34+
v8_oldstable = prev.callPackage ./packages/v8-oldstable { };
35+
})
2636
inputs.devshell.overlays.default
2737
];
2838
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/toolchain/gcc_toolchain.gni b/toolchain/gcc_toolchain.gni
2+
index 80e2a362a..df138c87b 100644
3+
--- a/build/toolchain/gcc_toolchain.gni
4+
+++ b/build/toolchain/gcc_toolchain.gni
5+
@@ -355,6 +355,8 @@ template("gcc_toolchain") {
6+
# AIX does not support either -D (deterministic output) or response
7+
# files.
8+
command = "$ar -X64 {{arflags}} -r -c -s {{output}} {{inputs}}"
9+
+ } else if (current_os == "mac") {
10+
+ command = "$ar {{arflags}} -r -c -s {{output}} {{inputs}}"
11+
} else {
12+
rspfile = "{{output}}.rsp"
13+
rspfile_content = "{{inputs}}"
14+
@@ -546,7 +548,7 @@ template("gcc_toolchain") {
15+
16+
start_group_flag = ""
17+
end_group_flag = ""
18+
- if (current_os != "aix") {
19+
+ if (current_os != "aix" && current_os != "mac") {
20+
# the "--start-group .. --end-group" feature isn't available on the aix ld.
21+
start_group_flag = "-Wl,--start-group"
22+
end_group_flag = "-Wl,--end-group "
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
{
2+
stdenv,
3+
lib,
4+
fetchgit,
5+
gn,
6+
ninja,
7+
python3,
8+
glib,
9+
pkg-config,
10+
icu,
11+
xcbuild,
12+
fetchpatch,
13+
llvmPackages,
14+
symlinkJoin,
15+
}:
16+
17+
# Copied from nixpkgs revision f311b2493888dbf499e769c8015de9b40e4d590d.
18+
19+
let
20+
version = "9.7.106.18";
21+
v8Src = fetchgit {
22+
url = "https://chromium.googlesource.com/v8/v8";
23+
rev = version;
24+
sha256 = "0cb3w733w1xn6zq9dsr43nx6llcg9hrmb2dkxairarj9c0igpzyh";
25+
};
26+
27+
git_url = "https://chromium.googlesource.com";
28+
29+
# This data is from the DEPS file in the root of a V8 checkout.
30+
deps = {
31+
"base/trace_event/common" = fetchgit {
32+
url = "${git_url}/chromium/src/base/trace_event/common.git";
33+
rev = "7f36dbc19d31e2aad895c60261ca8f726442bfbb";
34+
sha256 = "01b2fhbxznqbakxv42ivrzg6w8l7i9yrd9nf72d6p5xx9dm993j4";
35+
};
36+
"build" = fetchgit {
37+
url = "${git_url}/chromium/src/build.git";
38+
rev = "cf325916d58a194a935c26a56fcf6b525d1e2bf4";
39+
sha256 = "1ix4h1cpx9bvgln8590xh7lllhsd9w1hd5k9l1gx5yxxrmywd3s4";
40+
};
41+
"third_party/googletest/src" = fetchgit {
42+
url = "${git_url}/external/github.com/google/googletest.git";
43+
rev = "16f637fbf4ffc3f7a01fa4eceb7906634565242f";
44+
sha256 = "11012k3c3mxzdwcw2iparr9lrckafpyhqzclsj26hmfbgbdi0rrh";
45+
};
46+
"third_party/icu" = fetchgit {
47+
url = "${git_url}/chromium/deps/icu.git";
48+
rev = "eedbaf76e49d28465d9119b10c30b82906e606ff";
49+
sha256 = "0mppvx7wf9zlqjsfaa1cf06brh1fjb6nmiib0lhbb9hd55mqjdjj";
50+
};
51+
"third_party/zlib" = fetchgit {
52+
url = "${git_url}/chromium/src/third_party/zlib.git";
53+
rev = "6da1d53b97c89b07e47714d88cab61f1ce003c68";
54+
sha256 = "0v7ylmbwfwv6w6wp29qdf77kjjnfr2xzin08n0v1yvbhs01h5ppy";
55+
};
56+
"third_party/jinja2" = fetchgit {
57+
url = "${git_url}/chromium/src/third_party/jinja2.git";
58+
rev = "ee69aa00ee8536f61db6a451f3858745cf587de6";
59+
sha256 = "1fsnd5h0gisfp8bdsfd81kk5v4mkqf8z368c7qlm1qcwc4ri4x7a";
60+
};
61+
"third_party/markupsafe" = fetchgit {
62+
url = "${git_url}/chromium/src/third_party/markupsafe.git";
63+
rev = "1b882ef6372b58bfd55a3285f37ed801be9137cd";
64+
sha256 = "1jnjidbh03lhfaawimkjxbprmsgz4snr0jl06630dyd41zkdw5kr";
65+
};
66+
};
67+
68+
# See `gn_version` in DEPS.
69+
gnSrc = fetchgit {
70+
url = "https://gn.googlesource.com/gn";
71+
rev = "8926696a4186279489cc2b8d768533e61bba73d7";
72+
sha256 = "1084lnyb0a1khbgjvak05fcx6jy973wqvsf77n0alxjys18sg2yk";
73+
};
74+
75+
myGn = gn.overrideAttrs (oldAttrs: {
76+
version = "for-v8";
77+
src = gnSrc;
78+
configurePhase = ''
79+
runHook preConfigure
80+
81+
python build/gen.py --no-last-commit-position
82+
cat > out/last_commit_position.h << EOF
83+
#ifndef OUT_LAST_COMMIT_POSITION_H_
84+
#define OUT_LAST_COMMIT_POSITION_H_
85+
86+
#define LAST_COMMIT_POSITION_NUM 1942
87+
#define LAST_COMMIT_POSITION "1942 (8926696)"
88+
89+
#endif // OUT_LAST_COMMIT_POSITION_H_
90+
EOF
91+
92+
runHook postConfigure
93+
'';
94+
});
95+
in
96+
stdenv.mkDerivation rec {
97+
pname = "v8";
98+
inherit version;
99+
100+
doCheck = true;
101+
102+
patches = [
103+
./darwin.patch
104+
105+
# gcc-13 build fix for mixxign <cstdint> includes
106+
(fetchpatch {
107+
name = "gcc-13.patch";
108+
url = "https://chromium.googlesource.com/v8/v8/+/c2792e58035fcbaa16d0cb70998852fbeb5df4cc^!?format=TEXT";
109+
decode = "base64 -d";
110+
hash = "sha256-hoPAkSaCmzXflPFXaKUwVPLECMpt6N6/8m8mBSTAHbU=";
111+
})
112+
];
113+
114+
src = v8Src;
115+
116+
postUnpack = ''
117+
${lib.concatStringsSep "\n" (
118+
lib.mapAttrsToList (n: v: ''
119+
mkdir -p $sourceRoot/${n}
120+
cp -r ${v}/* $sourceRoot/${n}
121+
'') deps
122+
)}
123+
chmod u+w -R .
124+
'';
125+
126+
postPatch = ''
127+
${lib.optionalString stdenv.hostPlatform.isAarch64 ''
128+
substituteInPlace build/toolchain/linux/BUILD.gn \
129+
--replace 'toolprefix = "aarch64-linux-gnu-"' 'toolprefix = ""'
130+
''}
131+
${lib.optionalString stdenv.hostPlatform.isDarwin ''
132+
substituteInPlace build/config/compiler/compiler.gni \
133+
--replace 'strip_absolute_paths_from_debug_symbols = true' \
134+
'strip_absolute_paths_from_debug_symbols = false'
135+
substituteInPlace build/config/compiler/BUILD.gn \
136+
--replace 'current_toolchain == host_toolchain || !use_xcode_clang' \
137+
'false'
138+
''}
139+
${lib.optionalString stdenv.hostPlatform.isDarwin ''
140+
substituteInPlace build/config/compiler/BUILD.gn \
141+
--replace "-Wl,-fatal_warnings" ""
142+
''}
143+
touch build/config/gclient_args.gni
144+
sed '1i#include <utility>' -i src/heap/cppgc/prefinalizer-handler.h # gcc12
145+
'';
146+
147+
llvmCcAndBintools = symlinkJoin {
148+
name = "llvmCcAndBintools";
149+
paths = [
150+
stdenv.cc
151+
llvmPackages.llvm
152+
];
153+
};
154+
155+
gnFlags = [
156+
"use_custom_libcxx=false"
157+
"is_clang=${lib.boolToString stdenv.cc.isClang}"
158+
"use_sysroot=false"
159+
# "use_system_icu=true"
160+
"clang_use_chrome_plugins=false"
161+
"is_component_build=false"
162+
"v8_use_external_startup_data=false"
163+
"v8_monolithic=true"
164+
"is_debug=true"
165+
"is_official_build=false"
166+
"treat_warnings_as_errors=false"
167+
"v8_enable_i18n_support=true"
168+
"use_gold=false"
169+
# ''custom_toolchain="//build/toolchain/linux/unbundle:default"''
170+
''host_toolchain="//build/toolchain/linux/unbundle:default"''
171+
''v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"''
172+
]
173+
++ lib.optional stdenv.cc.isClang ''clang_base_path="${llvmCcAndBintools}"''
174+
++ lib.optional stdenv.hostPlatform.isDarwin "use_lld=false";
175+
176+
env.NIX_CFLAGS_COMPILE = toString (
177+
[ "-O2" ] ++ lib.optionals stdenv.cc.isClang [ "-Wno-error=enum-constexpr-conversion" ]
178+
);
179+
FORCE_MAC_SDK_MIN = stdenv.hostPlatform.sdkVer or "10.12";
180+
181+
nativeBuildInputs = [
182+
myGn
183+
ninja
184+
pkg-config
185+
python3
186+
]
187+
++ lib.optionals stdenv.hostPlatform.isDarwin [
188+
xcbuild
189+
llvmPackages.llvm
190+
python3.pkgs.setuptools
191+
];
192+
buildInputs = [
193+
glib
194+
icu
195+
];
196+
197+
ninjaFlags = [
198+
":d8"
199+
"v8_monolith"
200+
];
201+
202+
enableParallelBuilding = true;
203+
204+
installPhase = ''
205+
install -D d8 $out/bin/d8
206+
install -D -m644 obj/libv8_monolith.a $out/lib/libv8.a
207+
install -D -m644 icudtl.dat $out/share/v8/icudtl.dat
208+
ln -s libv8.a $out/lib/libv8_monolith.a
209+
cp -r ../../include $out
210+
211+
mkdir -p $out/lib/pkgconfig
212+
cat > $out/lib/pkgconfig/v8.pc << EOF
213+
Name: v8
214+
Description: V8 JavaScript Engine
215+
Version: ${version}
216+
Libs: -L$out/lib -lv8 -pthread
217+
Cflags: -I$out/include
218+
EOF
219+
'';
220+
221+
meta = with lib; {
222+
homepage = "https://v8.dev/";
223+
description = "Google's open source JavaScript engine";
224+
mainProgram = "d8";
225+
maintainers = with maintainers; [
226+
proglodyte
227+
matthewbauer
228+
];
229+
platforms = platforms.unix;
230+
license = licenses.bsd3;
231+
knownVulnerabilities = [ "Severely outdated with multiple publicly known vulnerabilities" ];
232+
};
233+
}

0 commit comments

Comments
 (0)