Skip to content

Commit 1c1ea21

Browse files
committed
tools: add some options and comments to shell.nix
1 parent 209a4fe commit 1c1ea21

File tree

2 files changed

+51
-36
lines changed

2 files changed

+51
-36
lines changed

shell.nix

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,63 @@
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

2133
let
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;
2539
in
2640
pkgs.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
}

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
{
@@ -12,7 +14,6 @@
1214
ngtcp2
1315
simdjson
1416
simdutf
15-
sqlite
1617
uvwasi
1718
zlib
1819
zstd
@@ -28,6 +29,11 @@
2829
})
2930
];
3031
};
32+
}
33+
// (pkgs.lib.optionalAttrs withSQLite {
34+
inherit (pkgs) sqlite;
35+
})
36+
// (pkgs.lib.optionalAttrs withSSL {
3137
openssl = pkgs.openssl.overrideAttrs (old: {
3238
version = "3.5.4";
3339
src = pkgs.fetchurl {
@@ -45,7 +51,7 @@
4551
"dev"
4652
];
4753
});
48-
}
54+
})
4955
// (pkgs.lib.optionalAttrs withTemporal {
5056
inherit (pkgs) temporal_capi;
5157
})

0 commit comments

Comments
 (0)