Skip to content

Commit 4b88ec1

Browse files
committed
tools: make v8.nix more stable
1 parent 9cbc49c commit 4b88ec1

File tree

2 files changed

+44
-43
lines changed

2 files changed

+44
-43
lines changed

shell.nix

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ let
4747

4848
needsRustCompiler = withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps;
4949

50-
buildInputs = builtins.attrValues sharedLibDeps ++ pkgs.lib.optional useSharedICU icu;
50+
nativeBuildInputs =
51+
pkgs.nodejs-slim_latest.nativeBuildInputs
52+
++ pkgs.lib.optionals needsRustCompiler [
53+
pkgs.cargo
54+
pkgs.rustc
55+
];
56+
buildInputs = pkgs.lib.optional useSharedICU icu;
57+
58+
# Put here only the configure flags that affect the V8 build
5159
configureFlags = [
5260
(
5361
if icu == null then
@@ -57,47 +65,31 @@ let
5765
)
5866
]
5967
++ extraConfigFlags
60-
++ pkgs.lib.optional (!withAmaro) "--without-amaro"
61-
++ pkgs.lib.optional (!withLief) "--without-lief"
62-
++ pkgs.lib.optional withQuic "--experimental-quic"
63-
++ pkgs.lib.optional (!withSQLite) "--without-sqlite"
64-
++ pkgs.lib.optional (!withSSL) "--without-ssl"
6568
++ pkgs.lib.optional withTemporal "--v8-enable-temporal-support"
66-
++ pkgs.lib.optional (ninja != null) "--ninja"
67-
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
6869
++ pkgs.lib.concatMap (name: [
6970
"--shared-${name}"
70-
"--shared-${name}-libpath=${pkgs.lib.getLib sharedLibDeps.${name}}/lib"
71-
"--shared-${name}-include=${pkgs.lib.getInclude sharedLibDeps.${name}}/include"
7271
]) (builtins.attrNames sharedLibDeps);
7372
in
7473
pkgs.mkShell {
75-
inherit (pkgs.nodejs-slim_latest) nativeBuildInputs;
74+
inherit nativeBuildInputs;
7675

7776
buildInputs =
78-
buildInputs
77+
builtins.attrValues sharedLibDeps
78+
++ buildInputs
7979
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) (
8080
if useSeparateDerivationForV8 == true then
81-
import ./tools/nix/v8.nix {
81+
pkgs.callPackage ./tools/nix/v8.nix {
8282
inherit
83-
pkgs
8483
configureFlags
8584
buildInputs
86-
needsRustCompiler
85+
nativeBuildInputs
8786
;
8887
}
8988
else
9089
useSeparateDerivationForV8
9190
);
9291

93-
packages =
94-
pkgs.lib.optional (ccache != null) ccache
95-
++ devTools
96-
++ benchmarkTools
97-
++ pkgs.lib.optionals needsRustCompiler [
98-
pkgs.cargo
99-
pkgs.rustc
100-
];
92+
packages = devTools ++ benchmarkTools ++ pkgs.lib.optional (ccache != null) ccache;
10193

10294
shellHook = pkgs.lib.optionalString (ccache != null) ''
10395
export CC="${pkgs.lib.getExe ccache} $CC"
@@ -118,7 +110,15 @@ pkgs.mkShell {
118110
]
119111
);
120112
CONFIG_FLAGS = builtins.toString (
121-
configureFlags ++ pkgs.lib.optional (useSeparateDerivationForV8 != false) "--without-bundled-v8"
113+
configureFlags
114+
++ pkgs.lib.optional (ninja != null) "--ninja"
115+
++ pkgs.lib.optional (!withAmaro) "--without-amaro"
116+
++ pkgs.lib.optional (!withLief) "--without-lief"
117+
++ pkgs.lib.optional withQuic "--experimental-quic"
118+
++ pkgs.lib.optional (!withSQLite) "--without-sqlite"
119+
++ pkgs.lib.optional (!withSSL) "--without-ssl"
120+
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
121+
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) "--without-bundled-v8"
122122
);
123123
NOSQLITE = pkgs.lib.optionalString (!withSQLite) "1";
124124
}

tools/nix/v8.nix

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# Derivation for Node.js CI (not officially supported for regular applications)
22
{
3-
pkgs ? import ./pkgs.nix { },
3+
stdenv,
4+
lib,
5+
patchutils,
6+
validatePkgConfig,
7+
nodejs-slim_latest,
8+
49
buildInputs ? [ ],
510
configureFlags ? [ ],
6-
needsRustCompiler ? false,
11+
12+
configureScript ? nodejs-slim_latest.configureScript,
13+
nativeBuildInputs ? nodejs-slim_latest.nativeBuildInputs,
14+
patches ? nodejs-slim_latest.patches,
715
}:
816

917
let
10-
nodejs = pkgs.nodejs-slim_latest;
18+
v8Dir = ../../deps/v8;
1119

1220
version =
1321
let
@@ -26,12 +34,12 @@ let
2634
else
2735
"${builtins.elemAt v8Version 0}.${builtins.elemAt v8Version 1}.${builtins.elemAt v8Version 2}.${builtins.elemAt v8Version 3}-${builtins.elemAt v8_embedder_string 0}";
2836
in
29-
pkgs.stdenv.mkDerivation (finalAttrs: {
37+
stdenv.mkDerivation (finalAttrs: {
3038
pname = "v8";
3139
inherit version;
3240
src =
3341
let
34-
inherit (pkgs.lib) fileset;
42+
inherit (lib) fileset;
3543
in
3644
fileset.toSource {
3745
root = ../../.;
@@ -61,7 +69,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
6169
# We need to patch tools/gyp/ to work from within Nix sandbox
6270
prePatch = ''
6371
patches=()
64-
for patch in ${pkgs.lib.concatStringsSep " " nodejs.patches}; do
72+
for patch in ${lib.concatStringsSep " " patches}; do
6573
filtered=$(mktemp)
6674
filterdiff -p1 -i 'tools/gyp/*' "$patch" > "$filtered"
6775
if [ -s "$filtered" ]; then
@@ -70,26 +78,19 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
7078
done
7179
'';
7280

73-
inherit (nodejs) configureScript;
74-
inherit configureFlags buildInputs;
81+
inherit configureScript configureFlags buildInputs;
7582

76-
nativeBuildInputs =
77-
nodejs.nativeBuildInputs
78-
++ [
79-
pkgs.patchutils
80-
pkgs.validatePkgConfig
81-
]
82-
++ pkgs.lib.optionals needsRustCompiler [
83-
pkgs.cargo
84-
pkgs.rustc
85-
];
83+
nativeBuildInputs = nativeBuildInputs ++ [
84+
patchutils
85+
validatePkgConfig
86+
];
8687

8788
buildPhase = ''
8889
ninja -v -C out/Release v8_snapshot v8_libplatform
8990
'';
9091
installPhase = ''
9192
${
92-
if pkgs.stdenv.buildPlatform.isDarwin then
93+
if stdenv.hostPlatform.isDarwin then
9394
# Darwin is excluded from creating thin archive in tools/gyp/pylib/gyp/generator/ninja.py:2488
9495
"install -Dm644 out/Release/lib* -t $out/lib"
9596
else

0 commit comments

Comments
 (0)