From 742f0fd58aafe5779fc14816ed92eb9dd7648228 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 30 Oct 2025 13:29:07 +0100 Subject: [PATCH] tools: extract Nix dependency lists to separate files This should improve the readability, as well as the UX of cherry-picking what dependency the user wants in their env. --- BUILDING.md | 2 +- shell.nix | 63 +++--------------------------------- tools/nix/benchmarkTools.nix | 9 ++++++ tools/nix/devTools.nix | 21 ++++++++++++ tools/nix/sharedLibDeps.nix | 38 ++++++++++++++++++++++ 5 files changed, 73 insertions(+), 60 deletions(-) create mode 100644 tools/nix/benchmarkTools.nix create mode 100644 tools/nix/devTools.nix create mode 100644 tools/nix/sharedLibDeps.nix diff --git a/BUILDING.md b/BUILDING.md index 569ea927220b94..51aa18c6b29858 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -294,7 +294,7 @@ that flag to use all the shared dependencies, or specify only some dependencies: ```bash cat -> .envrc <<'EOF' use nix --arg sharedLibDeps '{ - inherit (import {}) + inherit (import ./tools/nix/sharedLibDeps.nix {}) openssl zlib ; diff --git a/shell.nix b/shell.nix index b60bb881aa83c1..143955fa33ee44 100644 --- a/shell.nix +++ b/shell.nix @@ -1,68 +1,13 @@ { - pkgs ? import "${./tools/nix/pkgs.nix}" { }, + 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 - simdjson - simdutf - sqlite - uvwasi - zlib - zstd - ; - http-parser = pkgs.llhttp; - openssl = pkgs.openssl.overrideAttrs (old: { - version = "3.5.4"; - src = pkgs.fetchurl { - url = builtins.replaceStrings [ old.version ] [ "3.5.4" ] old.src.url; - hash = "sha256-lnMR+ElVMWlpvbHY1LmDcY70IzhjnGIexMNP3e81Xpk="; - }; - doCheck = false; - configureFlags = (old.configureFlags or [ ]) ++ [ - "no-docs" - "no-tests" - ]; - outputs = [ - "bin" - "out" - "dev" - ]; - }); - }, + sharedLibDeps ? import ./tools/nix/sharedLibDeps.nix { inherit pkgs; }, 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 - ], + devTools ? import ./tools/nix/devTools.nix { inherit pkgs ncu-path; }, + benchmarkTools ? import ./tools/nix/benchmarkTools.nix { inherit pkgs; }, extraConfigFlags ? [ "--without-npm" "--debug-node" diff --git a/tools/nix/benchmarkTools.nix b/tools/nix/benchmarkTools.nix new file mode 100644 index 00000000000000..62c744a552b7d1 --- /dev/null +++ b/tools/nix/benchmarkTools.nix @@ -0,0 +1,9 @@ +{ + pkgs ? import ./pkgs.nix { }, +}: +[ + pkgs.R + pkgs.rPackages.ggplot2 + pkgs.rPackages.plyr + pkgs.wrk +] diff --git a/tools/nix/devTools.nix b/tools/nix/devTools.nix new file mode 100644 index 00000000000000..474e365ceb4e34 --- /dev/null +++ b/tools/nix/devTools.nix @@ -0,0 +1,21 @@ +{ + pkgs ? import ./pkgs.nix { }, + ncu-path ? null, # Provide this if you want to use a local version of NCU +}: +[ + 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\" \"$@\"") + ] +) diff --git a/tools/nix/sharedLibDeps.nix b/tools/nix/sharedLibDeps.nix new file mode 100644 index 00000000000000..742d5701a5f530 --- /dev/null +++ b/tools/nix/sharedLibDeps.nix @@ -0,0 +1,38 @@ +{ + pkgs ? import ./pkgs.nix { }, +}: +{ + inherit (pkgs) + ada + brotli + c-ares + libuv + nghttp2 + nghttp3 + ngtcp2 + simdjson + simdutf + sqlite + uvwasi + zlib + zstd + ; + http-parser = pkgs.llhttp; + openssl = pkgs.openssl.overrideAttrs (old: { + version = "3.5.4"; + src = pkgs.fetchurl { + url = builtins.replaceStrings [ old.version ] [ "3.5.4" ] old.src.url; + hash = "sha256-lnMR+ElVMWlpvbHY1LmDcY70IzhjnGIexMNP3e81Xpk="; + }; + doCheck = false; + configureFlags = (old.configureFlags or [ ]) ++ [ + "no-docs" + "no-tests" + ]; + outputs = [ + "bin" + "out" + "dev" + ]; + }); +}