1818 withSQLite ? true ,
1919 withSSL ? true ,
2020 withTemporal ? false ,
21- sharedLibDeps ?
22- let
23- d = import ./tools/nix/sharedLibDeps.nix {
24- inherit
25- pkgs
26- withLief
27- withQuic
28- withSQLite
29- withSSL
30- withTemporal
31- ;
32- } ;
33- in
34- # To avoid conflicts with V8's bundled simdutf lib, it's easier to remove it when using a precompiled V8.
35- if ( useSeparateDerivationForV8 != false ) then builtins . removeAttrs d [ "simdutf" ] else d ,
21+ sharedLibDeps ? (
22+ import ./tools/nix/sharedLibDeps.nix {
23+ inherit
24+ pkgs
25+ withLief
26+ withQuic
27+ withSQLite
28+ withSSL
29+ withTemporal
30+ ;
31+ }
32+ ) ,
3633
3734 # dev tools (not needed to build Node.js, useful to maintain it)
3835 ncu-path ? null , # Provide this if you want to use a local version of NCU
4542 useSharedAda = builtins . hasAttr "ada" sharedLibDeps ;
4643 useSharedOpenSSL = builtins . hasAttr "openssl" sharedLibDeps ;
4744
48- needsRustCompiler = withTemporal && ! builtins . hasAttr "temporal_capi" sharedLibDeps ;
45+ useSharedTemporal = builtins . hasAttr "temporal_capi" sharedLibDeps ;
46+ needsRustCompiler = withTemporal && ! useSharedTemporal ;
4947
50- buildInputs = builtins . attrValues sharedLibDeps ++ pkgs . lib . optional useSharedICU icu ;
48+ nativeBuildInputs =
49+ pkgs . nodejs-slim_latest . nativeBuildInputs
50+ ++ pkgs . lib . optionals needsRustCompiler [
51+ pkgs . cargo
52+ pkgs . rustc
53+ ] ;
54+ buildInputs =
55+ pkgs . lib . optional useSharedICU icu
56+ ++ pkgs . lib . optional ( withTemporal && useSharedTemporal ) sharedLibDeps . temporal_capi ;
57+
58+ # Put here only the configure flags that affect the V8 build
5159 configureFlags = [
5260 (
5361 if icu == null then
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 ./. } "
68- ++ pkgs . lib . concatMap ( name : [
69- "--shared-${ name } "
70- "--shared-${ name } -libpath=${ pkgs . lib . getLib sharedLibDeps . ${ name } } /lib"
71- "--shared-${ name } -include=${ pkgs . lib . getInclude sharedLibDeps . ${ name } } /include"
72- ] ) ( builtins . attrNames sharedLibDeps ) ;
69+ ++ pkgs . lib . optional ( withTemporal && useSharedTemporal ) "--shared-temporal_capi" ;
7370in
7471pkgs . mkShell {
75- inherit ( pkgs . nodejs-slim_latest ) nativeBuildInputs ;
72+ inherit nativeBuildInputs ;
7673
7774 buildInputs =
78- buildInputs
75+ builtins . attrValues sharedLibDeps
76+ ++ buildInputs
7977 ++ pkgs . lib . optional ( useSeparateDerivationForV8 != false ) (
8078 if useSeparateDerivationForV8 == true then
81- import ./tools/nix/v8.nix {
82- inherit
83- pkgs
84- configureFlags
85- buildInputs
86- needsRustCompiler
87- ;
79+ let
80+ sharedLibsToMock = pkgs . callPackage ./tools/nix/non-v8-deps-mock.nix { } ;
81+ in
82+ pkgs . callPackage ./tools/nix/v8.nix {
83+ inherit nativeBuildInputs ;
84+
85+ configureFlags = configureFlags ++ sharedLibsToMock . configureFlags ++ [ "--ninja" ] ;
86+ buildInputs = buildInputs ++ [ sharedLibsToMock ] ;
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"
@@ -107,7 +99,33 @@ pkgs.mkShell {
10799 BUILD_WITH = if ( ninja != null ) then "ninja" else "make" ;
108100 NINJA = pkgs . lib . optionalString ( ninja != null ) "${ pkgs . lib . getExe ninja } " ;
109101 CONFIG_FLAGS = builtins . toString (
110- configureFlags ++ pkgs . lib . optional ( useSeparateDerivationForV8 != false ) "--without-bundled-v8"
102+ configureFlags
103+ ++ pkgs . lib . optional ( ninja != null ) "--ninja"
104+ ++ pkgs . lib . optional ( ! withAmaro ) "--without-amaro"
105+ ++ pkgs . lib . optional ( ! withLief ) "--without-lief"
106+ ++ pkgs . lib . optional withQuic "--experimental-quic"
107+ ++ pkgs . lib . optional ( ! withSQLite ) "--without-sqlite"
108+ ++ pkgs . lib . optional ( ! withSSL ) "--without-ssl"
109+ ++ pkgs . lib . optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${ builtins . toString ./. } "
110+ ++ pkgs . lib . optional ( useSeparateDerivationForV8 != false ) "--without-bundled-v8"
111+ ++
112+ pkgs . lib . concatMap
113+ ( name : [
114+ "--shared-${ name } "
115+ "--shared-${ name } -libpath=${ pkgs . lib . getLib sharedLibDeps . ${ name } } /lib"
116+ "--shared-${ name } -include=${ pkgs . lib . getInclude sharedLibDeps . ${ name } } /include"
117+ ] )
118+ (
119+ builtins . attrNames (
120+ if ( useSeparateDerivationForV8 != false ) then
121+ builtins . removeAttrs sharedLibDeps [
122+ "simdutf"
123+ "temporal_capi"
124+ ]
125+ else
126+ sharedLibDeps
127+ )
128+ )
111129 ) ;
112130 NOSQLITE = pkgs . lib . optionalString ( ! withSQLite ) "1" ;
113131}
0 commit comments