From 1c1ea216e0d4a74c76b773c0847abeaddda7fb06 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 30 Nov 2025 10:26:00 +0100 Subject: [PATCH 1/2] tools: add some options and comments to `shell.nix` --- shell.nix | 77 +++++++++++++++++++++---------------- tools/nix/sharedLibDeps.nix | 10 ++++- 2 files changed, 51 insertions(+), 36 deletions(-) diff --git a/shell.nix b/shell.nix index faa3446d80c952..a717a27f3af812 100644 --- a/shell.nix +++ b/shell.nix @@ -1,54 +1,63 @@ { pkgs ? import ./tools/nix/pkgs.nix { }, - loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding - withTemporal ? false, - 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; }, + + # Optional build tools / config ccache ? pkgs.ccache, + loadJSBuiltinsDynamically ? true, # Load `lib/**.js` from disk instead of embedding ninja ? pkgs.ninja, - devTools ? import ./tools/nix/devTools.nix { inherit pkgs ncu-path; }, - benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; }, extraConfigFlags ? [ "--without-npm" "--debug-node" - ] - ++ pkgs.lib.optionals withTemporal [ - "--v8-enable-temporal-support" ], + + # Build options + icu ? pkgs.icu, + 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 useSharedICU = if builtins.isString icu then icu == "system" else icu != null; useSharedAda = builtins.hasAttr "ada" sharedLibDeps; useSharedOpenSSL = builtins.hasAttr "openssl" sharedLibDeps; + + needsRustCompiler = withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps; in pkgs.mkShell { inherit (pkgs.nodejs_latest) nativeBuildInputs; buildInputs = builtins.attrValues sharedLibDeps ++ pkgs.lib.optional useSharedICU icu; - packages = [ - ccache - ] - ++ devTools - ++ benchmarkTools - ++ pkgs.lib.optionals (withTemporal && !builtins.hasAttr "temporal_capi" sharedLibDeps) [ - pkgs.cargo - pkgs.rustc - ]; + packages = + pkgs.lib.optional (ccache != null) ccache + ++ devTools + ++ benchmarkTools + ++ pkgs.lib.optionals needsRustCompiler [ + pkgs.cargo + pkgs.rustc + ]; - shellHook = - if (ccache != null) then - '' - export CC="${pkgs.lib.getExe ccache} $CC" - export CXX="${pkgs.lib.getExe ccache} $CXX" - '' - else - ""; + 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 = 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 "," ( [ ] ++ pkgs.lib.optionals useSharedAda [ @@ -70,12 +79,11 @@ pkgs.mkShell { ) ] ++ extraConfigFlags - ++ pkgs.lib.optionals (ninja != null) [ - "--ninja" - ] - ++ pkgs.lib.optionals loadJSBuiltinsDynamically [ - "--node-builtin-modules-path=${builtins.toString ./.}" - ] + ++ pkgs.lib.optional (!withSQLite) "--without-sqlite" + ++ pkgs.lib.optional (!withSSL) "--without-ssl" + ++ pkgs.lib.optional withTemporal "--v8-enable-temporal-support" + ++ pkgs.lib.optional (ninja != null) "--ninja" + ++ pkgs.lib.optional 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=${ @@ -86,4 +94,5 @@ pkgs.mkShell { }/include" ]) (builtins.attrNames sharedLibDeps) ); + NOSQLITE = pkgs.lib.optionalString (!withSQLite) "1"; } diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix index ba006fc9ce39ef..7142c4c766588c 100644 --- a/tools/nix/sharedLibDeps.nix +++ b/tools/nix/sharedLibDeps.nix @@ -1,5 +1,7 @@ { pkgs ? import ./pkgs.nix { }, + withSQLite ? true, + withSSL ? true, withTemporal ? false, }: { @@ -12,7 +14,6 @@ ngtcp2 simdjson simdutf - sqlite uvwasi zlib zstd @@ -28,6 +29,11 @@ }) ]; }; +} +// (pkgs.lib.optionalAttrs withSQLite { + inherit (pkgs) sqlite; +}) +// (pkgs.lib.optionalAttrs withSSL { openssl = pkgs.openssl.overrideAttrs (old: { version = "3.5.4"; src = pkgs.fetchurl { @@ -45,7 +51,7 @@ "dev" ]; }); -} +}) // (pkgs.lib.optionalAttrs withTemporal { inherit (pkgs) temporal_capi; }) From e6108fc9eb25aa03322960048b4983df664faad7 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 1 Dec 2025 14:21:19 +0100 Subject: [PATCH 2/2] fixup! tools: add some options and comments to `shell.nix` add `withAmaro` param --- shell.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell.nix b/shell.nix index a717a27f3af812..cae2418ca20f4d 100644 --- a/shell.nix +++ b/shell.nix @@ -12,6 +12,7 @@ # Build options icu ? pkgs.icu, + withAmaro ? true, withSQLite ? true, withSSL ? true, withTemporal ? false, @@ -79,6 +80,7 @@ pkgs.mkShell { ) ] ++ extraConfigFlags + ++ pkgs.lib.optional (!withAmaro) "--without-amaro" ++ pkgs.lib.optional (!withSQLite) "--without-sqlite" ++ pkgs.lib.optional (!withSSL) "--without-ssl" ++ pkgs.lib.optional withTemporal "--v8-enable-temporal-support"