-
-
Notifications
You must be signed in to change notification settings - Fork 36.3k
Expand file tree
/
Copy pathshell.nix
More file actions
162 lines (148 loc) Β· 5.29 KB
/
Copy pathshell.nix
File metadata and controls
162 lines (148 loc) Β· 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{
pkgs ? import ./tools/nix/pkgs.nix { },
# Optional build tools / config
ccache ? pkgs.ccache,
loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding
ninja ? pkgs.ninja,
extraConfigFlags ? [
"--debug-node"
],
useSeparateDerivationForV8 ? false, # to help CI better managed its binary cache, not recommended outside of CI usage.
# Build options
icu ? pkgs.icu,
withAmaro ? true,
withLief ? true,
withQuic ? false,
withSQLite ? true,
withFFI ? true,
withSSL ? true,
withTemporal ? false,
withPerfetto ? false,
sharedLibDeps ? (
import ./tools/nix/sharedLibDeps.nix {
inherit
pkgs
withLief
withQuic
withSQLite
withFFI
withSSL
withTemporal
;
}
),
# PKCS#11 fixture for `test/parallel/test-crypto-key-store-pkcs11.js`. `true`
# builds the one from tools/nix/pkcs11.nix against the OpenSSL being linked,
# which needs a shared OpenSSL >= 3 and a platform nixpkgs ships
# pkcs11-provider for. `false` and `null` disable it, any other value is used
# as the fixture itself.
pkcs11 ? false,
# dev tools (not needed to build Node.js, useful to maintain it)
ncu-path ? null, # Provide this if you want to use a local version of NCU
devTools ? import ./tools/nix/devTools.nix { inherit pkgs ncu-path; },
benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; },
}:
let
useSharedICU = if builtins.isString icu then icu == "system" else icu != null;
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;
useSharedTemporal = builtins.hasAttr "temporal_capi" sharedLibDeps;
needsRustCompiler = withTemporal && !useSharedTemporal;
usePkcs11 = pkcs11 != false && pkcs11 != null;
pkcs11Fixture =
if pkcs11 == true then
import ./tools/nix/pkcs11.nix {
inherit pkgs;
inherit (sharedLibDeps) openssl;
}
else
pkcs11;
nativeBuildInputs =
pkgs.nodejs-slim_latest.nativeBuildInputs
++ pkgs.lib.optionals needsRustCompiler [
pkgs.cargo
pkgs.rustc
];
buildInputs =
pkgs.lib.optional useSharedICU icu
++ pkgs.lib.optional (withTemporal && useSharedTemporal) sharedLibDeps.temporal_capi;
# Put here only the configure flags that affect the V8 build
configureFlags = [
(
if icu == null then
"--without-intl"
else
"--with-intl=${if useSharedICU then "system" else icu}-icu"
)
"--v8-${if withTemporal then "enable" else "disable"}-temporal-support"
]
++ pkgs.lib.optional (withTemporal && useSharedTemporal) "--shared-temporal_capi"
++ pkgs.lib.optional withPerfetto "--with-perfetto";
in
pkgs.mkShell (
{
inherit nativeBuildInputs;
buildInputs =
builtins.attrValues sharedLibDeps
++ buildInputs
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) (
if useSeparateDerivationForV8 == true then
let
sharedLibsToMock = pkgs.callPackage ./tools/nix/non-v8-deps-mock.nix { };
in
pkgs.callPackage ./tools/nix/v8.nix {
inherit nativeBuildInputs icu;
configureFlags = configureFlags ++ sharedLibsToMock.configureFlags ++ [ "--ninja" ];
buildInputs = buildInputs ++ [ sharedLibsToMock ];
}
else
useSeparateDerivationForV8
);
packages = devTools ++ benchmarkTools ++ pkgs.lib.optional (ccache != null) ccache;
shellHook = pkgs.lib.optionalString (ccache != null) ''
export CC="${pkgs.lib.getExe ccache} $CC"
export CXX="${pkgs.lib.getExe ccache} $CXX"
'';
BUILD_WITH = if (ninja != null) then "ninja" else "make";
NINJA = pkgs.lib.optionalString (ninja != null) "${pkgs.lib.getExe ninja}";
CONFIG_FLAGS = builtins.toString (
configureFlags
++ extraConfigFlags
++ pkgs.lib.optional (ninja != null) "--ninja"
++ pkgs.lib.optional (!withAmaro) "--without-amaro"
++ pkgs.lib.optional (!withLief) "--without-lief"
++ pkgs.lib.optional withQuic "--experimental-quic"
++ pkgs.lib.optional (!withSQLite) "--without-sqlite"
++ pkgs.lib.optional (!withFFI) "--without-ffi"
++ pkgs.lib.optional (!withSSL) "--without-ssl"
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
++ pkgs.lib.optional (useSeparateDerivationForV8 != false) "--without-bundled-v8"
++
pkgs.lib.concatMap
(name: [
"--shared-${name}"
"--shared-${name}-libpath=${pkgs.lib.getLib sharedLibDeps.${name}}/lib"
"--shared-${name}-include=${pkgs.lib.getInclude sharedLibDeps.${name}}/include"
])
(
builtins.attrNames (
if (useSeparateDerivationForV8 != false) then
builtins.removeAttrs sharedLibDeps [
"simdutf"
"temporal_capi"
]
else
sharedLibDeps
)
)
);
}
// pkgs.lib.optionalAttrs (!withSQLite) {
NOSQLITE = "1";
}
// pkgs.lib.optionalAttrs usePkcs11 {
NODE_TEST_PKCS11_OPENSSL_CONF = "${pkcs11Fixture.opensslConf}";
NODE_TEST_PKCS11_PIN = pkcs11Fixture.softhsmDir.pin;
NODE_TEST_PKCS11_SOFTHSM_DIR = "${pkcs11Fixture.softhsmDir}";
}
)