Skip to content

Commit 2ceaf6e

Browse files
aduh95RafaelGSS
authored andcommitted
tools: add some options and comments to shell.nix
PR-URL: #60911 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 6d5f9ff commit 2ceaf6e

2 files changed

Lines changed: 53 additions & 36 deletions

File tree

‎shell.nix‎

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,64 @@
11
{
22
pkgs ? import./tools/nix/pkgs.nix{},
3-
loadJSBuiltinsDynamically ? true,# Load `lib/**.js` from disk instead of embedding
4-
withTemporal ? false,
5-
ncu-path ? null,# Provide this if you want to use a local version of NCU
6-
icu ? pkgs.icu,
7-
sharedLibDeps ? import./tools/nix/sharedLibDeps.nix{inheritpkgswithTemporal;},
3+
4+
# Optional build tools / config
85
ccache ? pkgs.ccache,
6+
loadJSBuiltinsDynamically ? true,# Load `lib/**.js` from disk instead of embedding
97
ninja ? pkgs.ninja,
10-
devTools ? import./tools/nix/devTools.nix{inheritpkgsncu-path;},
11-
benchmarkTools ? import./tools/nix/benchmarkTools.nix{inheritpkgs;},
128
extraConfigFlags ? [
139
"--without-npm"
1410
"--debug-node"
15-
]
16-
++pkgs.lib.optionalswithTemporal[
17-
"--v8-enable-temporal-support"
1811
],
12+
13+
# Build options
14+
icu ? pkgs.icu,
15+
withAmaro ? true,
16+
withSQLite ? true,
17+
withSSL ? true,
18+
withTemporal ? false,
19+
sharedLibDeps ? import./tools/nix/sharedLibDeps.nix{
20+
inherit
21+
pkgs
22+
withSQLite
23+
withSSL
24+
withTemporal
25+
;
26+
},
27+
28+
# dev tools (not needed to build Node.js, useful to maintain it)
29+
ncu-path ? null,# Provide this if you want to use a local version of NCU
30+
devTools ? import./tools/nix/devTools.nix{inheritpkgsncu-path;},
31+
benchmarkTools ? import./tools/nix/benchmarkTools.nix{inheritpkgs;},
1932
}:
2033

2134
let
2235
useSharedICU=ifbuiltins.isStringicuthenicu=="system"elseicu!=null;
2336
useSharedAda=builtins.hasAttr"ada"sharedLibDeps;
2437
useSharedOpenSSL=builtins.hasAttr"openssl"sharedLibDeps;
38+
39+
needsRustCompiler=withTemporal&&!builtins.hasAttr"temporal_capi"sharedLibDeps;
2540
in
2641
pkgs.mkShell{
2742
inherit(pkgs.nodejs_latest)nativeBuildInputs;
2843

2944
buildInputs=builtins.attrValuessharedLibDeps++pkgs.lib.optionaluseSharedICUicu;
3045

31-
packages=[
32-
ccache
33-
]
34-
++devTools
35-
++benchmarkTools
36-
++pkgs.lib.optionals(withTemporal&&!builtins.hasAttr"temporal_capi"sharedLibDeps)[
37-
pkgs.cargo
38-
pkgs.rustc
39-
];
46+
packages=
47+
pkgs.lib.optional(ccache!=null)ccache
48+
++devTools
49+
++benchmarkTools
50+
++pkgs.lib.optionalsneedsRustCompiler[
51+
pkgs.cargo
52+
pkgs.rustc
53+
];
4054

41-
shellHook=
42-
if(ccache!=null)then
43-
''
44-
export CC="${pkgs.lib.getExeccache} $CC"
45-
export CXX="${pkgs.lib.getExeccache} $CXX"
46-
''
47-
else
48-
"";
55+
shellHook=pkgs.lib.optionalString(ccache!=null)''
56+
export CC="${pkgs.lib.getExeccache} $CC"
57+
export CXX="${pkgs.lib.getExeccache} $CXX"
58+
'';
4959

5060
BUILD_WITH=if(ninja!=null)then"ninja"else"make";
51-
NINJA=if(ninja!=null)then"${pkgs.lib.getExeninja}"else"";
61+
NINJA=pkgs.lib.optionalString(ninja!=null)"${pkgs.lib.getExeninja}";
5262
CI_SKIP_TESTS=pkgs.lib.concatStringsSep","(
5363
[]
5464
++pkgs.lib.optionalsuseSharedAda[
@@ -70,12 +80,12 @@ pkgs.mkShell {
7080
)
7181
]
7282
++extraConfigFlags
73-
++pkgs.lib.optionals(ninja!=null)[
74-
"--ninja"
75-
]
76-
++pkgs.lib.optionalsloadJSBuiltinsDynamically[
77-
"--node-builtin-modules-path=${builtins.toString./.}"
78-
]
83+
++pkgs.lib.optional(!withAmaro)"--without-amaro"
84+
++pkgs.lib.optional(!withSQLite)"--without-sqlite"
85+
++pkgs.lib.optional(!withSSL)"--without-ssl"
86+
++pkgs.lib.optionalwithTemporal"--v8-enable-temporal-support"
87+
++pkgs.lib.optional(ninja!=null)"--ninja"
88+
++pkgs.lib.optionalloadJSBuiltinsDynamically"--node-builtin-modules-path=${builtins.toString./.}"
7989
++pkgs.lib.concatMap(name: [
8090
"--shared-${builtins.replaceStrings["c-ares"]["cares"]name}"
8191
"--shared-${builtins.replaceStrings["c-ares"]["cares"]name}-libpath=${
@@ -86,4 +96,5 @@ pkgs.mkShell {
8696
}/include"
8797
])(builtins.attrNamessharedLibDeps)
8898
);
99+
NOSQLITE=pkgs.lib.optionalString(!withSQLite)"1";
89100
}

‎tools/nix/sharedLibDeps.nix‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
pkgs ? import./pkgs.nix{},
3+
withSQLite ? true,
4+
withSSL ? true,
35
withTemporal ? false,
46
}:
57
{
@@ -13,12 +15,16 @@
1315
ngtcp2
1416
simdjson
1517
simdutf
16-
sqlite
1718
uvwasi
1819
zlib
1920
zstd
2021
;
2122
http-parser=pkgs.llhttp;
23+
}
24+
//(pkgs.lib.optionalAttrswithSQLite{
25+
inherit(pkgs)sqlite;
26+
})
27+
//(pkgs.lib.optionalAttrswithSSL{
2228
openssl=pkgs.openssl.overrideAttrs(old: {
2329
version="3.5.4";
2430
src=pkgs.fetchurl{
@@ -36,7 +42,7 @@
3642
"dev"
3743
];
3844
});
39-
}
45+
})
4046
//(pkgs.lib.optionalAttrswithTemporal{
4147
inherit(pkgs)temporal_capi;
4248
})

0 commit comments

Comments
 (0)