forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.nix
More file actions
120 lines (115 loc) Β· 3.05 KB
/
shell.nix
File metadata and controls
120 lines (115 loc) Β· 3.05 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
{
pkgs ? import "${./tools/nix/pkgs.nix}" { },
loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding
ncu-path ? null, # Provide this if you want to use a local version of NCU
icu ? pkgs.icu,
sharedLibDeps ? {
inherit (pkgs)
ada
brotli
c-ares
libuv
nghttp2
nghttp3
ngtcp2
openssl
simdjson
simdutf
sqlite
uvwasi
zlib
zstd
;
http-parser = pkgs.llhttp;
},
ccache ? pkgs.ccache,
ninja ? pkgs.ninja,
devTools ? [
pkgs.curl
pkgs.gh
pkgs.git
pkgs.jq
pkgs.shellcheck
]
++ (
if (ncu-path == null) then
[ pkgs.node-core-utils ]
else
[
(pkgs.writeShellScriptBin "git-node" "exec \"${ncu-path}/bin/git-node.js\" \"$@\"")
(pkgs.writeShellScriptBin "ncu-ci" "exec \"${ncu-path}/bin/ncu-ci.js\" \"$@\"")
(pkgs.writeShellScriptBin "ncu-config" "exec \"${ncu-path}/bin/ncu-config.js\" \"$@\"")
]
),
benchmarkTools ? [
pkgs.R
pkgs.rPackages.ggplot2
pkgs.rPackages.plyr
pkgs.wrk
],
extraConfigFlags ? [
"--without-npm"
"--debug-node"
],
}:
let
useSharedICU = if builtins.isString icu then icu == "system" else icu != null;
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;
in
pkgs.mkShell {
inherit (pkgs.nodejs_latest) nativeBuildInputs;
buildInputs = builtins.attrValues sharedLibDeps ++ pkgs.lib.optionals useSharedICU [ icu ];
packages = [
ccache
]
++ devTools
++ benchmarkTools;
shellHook =
if (ccache != null) then
''
export CC="${pkgs.lib.getExe ccache} $CC"
export CXX="${pkgs.lib.getExe ccache} $CXX"
''
else
"";
BUILD_WITH = if (ninja != null) then "ninja" else "make";
NINJA = if (ninja != null) then "${pkgs.lib.getExe ninja}" else "";
CI_SKIP_TESTS = pkgs.lib.concatStringsSep "," (
[ ]
++ pkgs.lib.optionals useSharedAda [
# Different versions of Ada affect the WPT tests
"test-url"
]
++ pkgs.lib.optionals useSharedOpenSSL [
# Path to the openssl.cnf is different from the expected one
"test-strace-openat-openssl"
]
);
CONFIG_FLAGS = builtins.toString (
[
(
if icu == null then
"--without-intl"
else
"--with-intl=${if useSharedICU then "system" else icu}-icu"
)
]
++ extraConfigFlags
++ pkgs.lib.optionals (ninja != null) [
"--ninja"
]
++ pkgs.lib.optionals loadJSBuiltinsDynamically [
"--node-builtin-modules-path=${builtins.toString ./.}"
]
++ pkgs.lib.concatMap (name: [
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}"
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}-libpath=${
pkgs.lib.getLib sharedLibDeps.${name}
}/lib"
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}-include=${
pkgs.lib.getInclude sharedLibDeps.${name}
}/include"
]) (builtins.attrNames sharedLibDeps)
);
}