mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
tools: add some options and comments to shell.nix
PR-URL: https://github.com/nodejs/node/pull/60911 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
79
shell.nix
79
shell.nix
@@ -1,54 +1,64 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import ./tools/nix/pkgs.nix { },
|
pkgs ? import ./tools/nix/pkgs.nix { },
|
||||||
loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding
|
|
||||||
withTemporal ? false,
|
# Optional build tools / config
|
||||||
ncu-path ? null, # Provide this if you want to use a local version of NCU
|
|
||||||
icu ? pkgs.icu,
|
|
||||||
sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix { inherit pkgs withTemporal; },
|
|
||||||
ccache ? pkgs.ccache,
|
ccache ? pkgs.ccache,
|
||||||
|
loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding
|
||||||
ninja ? pkgs.ninja,
|
ninja ? pkgs.ninja,
|
||||||
devTools ? import ./tools/nix/devTools.nix { inherit pkgs ncu-path; },
|
|
||||||
benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; },
|
|
||||||
extraConfigFlags ? [
|
extraConfigFlags ? [
|
||||||
"--without-npm"
|
"--without-npm"
|
||||||
"--debug-node"
|
"--debug-node"
|
||||||
]
|
|
||||||
++ pkgs.lib.optionals withTemporal [
|
|
||||||
"--v8-enable-temporal-support"
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
# Build options
|
||||||
|
icu ? pkgs.icu,
|
||||||
|
withAmaro ? true,
|
||||||
|
withSQLite ? true,
|
||||||
|
withSSL ? true,
|
||||||
|
withTemporal ? false,
|
||||||
|
sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix {
|
||||||
|
inherit
|
||||||
|
pkgs
|
||||||
|
withSQLite
|
||||||
|
withSSL
|
||||||
|
withTemporal
|
||||||
|
;
|
||||||
|
},
|
||||||
|
|
||||||
|
# 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
|
let
|
||||||
useSharedICU = if builtins.isString icu then icu == "system" else icu != null;
|
useSharedICU = if builtins.isString icu then icu == "system" else icu != null;
|
||||||
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
|
useSharedAda = builtins.hasAttr "ada" sharedLibDeps;
|
||||||
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;
|
useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps;
|
||||||
|
|
||||||
|
needsRustCompiler = withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps;
|
||||||
in
|
in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
inherit (pkgs.nodejs_latest) nativeBuildInputs;
|
inherit (pkgs.nodejs_latest) nativeBuildInputs;
|
||||||
|
|
||||||
buildInputs = builtins.attrValues sharedLibDeps ++ pkgs.lib.optional useSharedICU icu;
|
buildInputs = builtins.attrValues sharedLibDeps ++ pkgs.lib.optional useSharedICU icu;
|
||||||
|
|
||||||
packages = [
|
packages =
|
||||||
ccache
|
pkgs.lib.optional (ccache != null) ccache
|
||||||
]
|
++ devTools
|
||||||
++ devTools
|
++ benchmarkTools
|
||||||
++ benchmarkTools
|
++ pkgs.lib.optionals needsRustCompiler [
|
||||||
++ pkgs.lib.optionals (withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps) [
|
pkgs.cargo
|
||||||
pkgs.cargo
|
pkgs.rustc
|
||||||
pkgs.rustc
|
];
|
||||||
];
|
|
||||||
|
|
||||||
shellHook =
|
shellHook = pkgs.lib.optionalString (ccache != null) ''
|
||||||
if (ccache != null) then
|
export CC="${pkgs.lib.getExe ccache} $CC"
|
||||||
''
|
export CXX="${pkgs.lib.getExe ccache} $CXX"
|
||||||
export CC="${pkgs.lib.getExe ccache} $CC"
|
'';
|
||||||
export CXX="${pkgs.lib.getExe ccache} $CXX"
|
|
||||||
''
|
|
||||||
else
|
|
||||||
"";
|
|
||||||
|
|
||||||
BUILD_WITH = if (ninja != null) then "ninja" else "make";
|
BUILD_WITH = if (ninja != null) then "ninja" else "make";
|
||||||
NINJA = if (ninja != null) then "${pkgs.lib.getExe ninja}" else "";
|
NINJA = pkgs.lib.optionalString (ninja != null) "${pkgs.lib.getExe ninja}";
|
||||||
CI_SKIP_TESTS = pkgs.lib.concatStringsSep "," (
|
CI_SKIP_TESTS = pkgs.lib.concatStringsSep "," (
|
||||||
[ ]
|
[ ]
|
||||||
++ pkgs.lib.optionals useSharedAda [
|
++ pkgs.lib.optionals useSharedAda [
|
||||||
@@ -70,12 +80,12 @@ pkgs.mkShell {
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
++ extraConfigFlags
|
++ extraConfigFlags
|
||||||
++ pkgs.lib.optionals (ninja != null) [
|
++ pkgs.lib.optional (!withAmaro) "--without-amaro"
|
||||||
"--ninja"
|
++ pkgs.lib.optional (!withSQLite) "--without-sqlite"
|
||||||
]
|
++ pkgs.lib.optional (!withSSL) "--without-ssl"
|
||||||
++ pkgs.lib.optionals loadJSBuiltinsDynamically [
|
++ pkgs.lib.optional withTemporal "--v8-enable-temporal-support"
|
||||||
"--node-builtin-modules-path=${builtins.toString ./.}"
|
++ pkgs.lib.optional (ninja != null) "--ninja"
|
||||||
]
|
++ pkgs.lib.optional loadJSBuiltinsDynamically "--node-builtin-modules-path=${builtins.toString ./.}"
|
||||||
++ pkgs.lib.concatMap (name: [
|
++ pkgs.lib.concatMap (name: [
|
||||||
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}"
|
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}"
|
||||||
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}-libpath=${
|
"--shared-${builtins.replaceStrings [ "c-ares" ] [ "cares" ] name}-libpath=${
|
||||||
@@ -86,4 +96,5 @@ pkgs.mkShell {
|
|||||||
}/include"
|
}/include"
|
||||||
]) (builtins.attrNames sharedLibDeps)
|
]) (builtins.attrNames sharedLibDeps)
|
||||||
);
|
);
|
||||||
|
NOSQLITE = pkgs.lib.optionalString (!withSQLite) "1";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import ./pkgs.nix { },
|
pkgs ? import ./pkgs.nix { },
|
||||||
|
withSQLite ? true,
|
||||||
|
withSSL ? true,
|
||||||
withTemporal ? false,
|
withTemporal ? false,
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
@@ -12,7 +14,6 @@
|
|||||||
ngtcp2
|
ngtcp2
|
||||||
simdjson
|
simdjson
|
||||||
simdutf
|
simdutf
|
||||||
sqlite
|
|
||||||
uvwasi
|
uvwasi
|
||||||
zlib
|
zlib
|
||||||
zstd
|
zstd
|
||||||
@@ -28,6 +29,11 @@
|
|||||||
})
|
})
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
// (pkgs.lib.optionalAttrs withSQLite {
|
||||||
|
inherit (pkgs) sqlite;
|
||||||
|
})
|
||||||
|
// (pkgs.lib.optionalAttrs withSSL {
|
||||||
openssl = pkgs.openssl.overrideAttrs (old: {
|
openssl = pkgs.openssl.overrideAttrs (old: {
|
||||||
version = "3.5.4";
|
version = "3.5.4";
|
||||||
src = pkgs.fetchurl {
|
src = pkgs.fetchurl {
|
||||||
@@ -45,7 +51,7 @@
|
|||||||
"dev"
|
"dev"
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
}
|
})
|
||||||
// (pkgs.lib.optionalAttrs withTemporal {
|
// (pkgs.lib.optionalAttrs withTemporal {
|
||||||
inherit (pkgs) temporal_capi;
|
inherit (pkgs) temporal_capi;
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user