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 { inherit pkgs withTemporal ; } ,
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 { inherit pkgs ncu-path ; } ,
11- benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs ; } ,
128 extraConfigFlags ? [
139 "--without-npm"
1410 "--debug-node"
15- ]
16- ++ pkgs . lib . optionals withTemporal [
17- "--v8-enable-temporal-support"
1811 ] ,
12+
13+ # Build options
14+ icu ? pkgs . icu ,
15+ withSQLite ? true ,
16+ withSSL ? true ,
17+ withTemporal ? false ,
18+ sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix {
19+ inherit
20+ pkgs
21+ withSQLite
22+ withSSL
23+ withTemporal
24+ ;
25+ } ,
26+
27+ # dev tools (not needed to build Node.js, useful to maintain it)
28+ ncu-path ? null , # Provide this if you want to use a local version of NCU
29+ devTools ? import ./tools/nix/devTools.nix { inherit pkgs ncu-path ; } ,
30+ benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs ; } ,
1931} :
2032
2133let
2234 useSharedICU = if builtins . isString icu then icu == "system" else icu != null ;
2335 useSharedAda = builtins . hasAttr "ada" sharedLibDeps ;
2436 useSharedOpenSSL = builtins . hasAttr "openssl" sharedLibDeps ;
37+
38+ needsRustCompiler = withTemporal && ! builtins . hasAttr "temporal_capi" sharedLibDeps ;
2539in
2640pkgs . mkShell {
2741 inherit ( pkgs . nodejs_latest ) nativeBuildInputs ;
2842
2943 buildInputs = builtins . attrValues sharedLibDeps ++ pkgs . lib . optional useSharedICU icu ;
3044
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- ] ;
45+ packages =
46+ pkgs . lib . optional ( ccache != null ) ccache
47+ ++ devTools
48+ ++ benchmarkTools
49+ ++ pkgs . lib . optionals needsRustCompiler [
50+ pkgs . cargo
51+ pkgs . rustc
52+ ] ;
4053
41- shellHook =
42- if ( ccache != null ) then
43- ''
44- export CC="${ pkgs . lib . getExe ccache } $CC"
45- export CXX="${ pkgs . lib . getExe ccache } $CXX"
46- ''
47- else
48- "" ;
54+ shellHook = pkgs . lib . optionalString ( ccache != null ) ''
55+ export CC="${ pkgs . lib . getExe ccache } $CC"
56+ export CXX="${ pkgs . lib . getExe ccache } $CXX"
57+ '' ;
4958
5059 BUILD_WITH = if ( ninja != null ) then "ninja" else "make" ;
51- NINJA = if ( ninja != null ) then "${ pkgs . lib . getExe ninja } " else " ";
60+ NINJA = pkgs . lib . optionalString ( ninja != null ) "${ pkgs . lib . getExe ninja } " ;
5261 CI_SKIP_TESTS = pkgs . lib . concatStringsSep "," (
5362 [ ]
5463 ++ pkgs . lib . optionals useSharedAda [
@@ -70,12 +79,11 @@ pkgs.mkShell {
7079 )
7180 ]
7281 ++ extraConfigFlags
73- ++ pkgs . lib . optionals ( ninja != null ) [
74- "--ninja"
75- ]
76- ++ pkgs . lib . optionals loadJSBuiltinsDynamically [
77- "--node-builtin-modules-path=${ builtins . toString ./. } "
78- ]
82+ ++ pkgs . lib . optional ( ! withSQLite ) "--without-sqlite"
83+ ++ pkgs . lib . optional ( ! withSSL ) "--without-ssl"
84+ ++ pkgs . lib . optional withTemporal "--v8-enable-temporal-support"
85+ ++ pkgs . lib . optional ( ninja != null ) "--ninja"
86+ ++ pkgs . lib . optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${ builtins . toString ./. } "
7987 ++ pkgs . lib . concatMap ( name : [
8088 "--shared-${ builtins . replaceStrings [ "c-ares" ] [ "cares" ] name } "
8189 "--shared-${ builtins . replaceStrings [ "c-ares" ] [ "cares" ] name } -libpath=${
@@ -86,4 +94,5 @@ pkgs.mkShell {
8694 } /include"
8795 ] ) ( builtins . attrNames sharedLibDeps )
8896 ) ;
97+ NOSQLITE = pkgs . lib . optionalString ( ! withSQLite ) "1" ;
8998}
0 commit comments