diff --git a/doc/release-notes/rl-2605.section.md b/doc/release-notes/rl-2605.section.md index 50542ade0227b..88e88bef70650 100644 --- a/doc/release-notes/rl-2605.section.md +++ b/doc/release-notes/rl-2605.section.md @@ -143,7 +143,7 @@ - `services.openssh.settings.AcceptEnv` now explicitly defined as an option that takes a list of strings, to facilitate option merging. Setting it to a string value is no longer supported. -- `nodejs-slim` has a `npm` output, and `nodejs` no longer has a `libv8` output. +- `nodejs-slim` has a `npm` and a `corepack` outputs, and `nodejs` no longer has a `libv8` output. - All Xfce packages have been moved to top level (e.g. if you previously added `pkgs.xfce.xfce4-whiskermenu-plugin` to `environment.systemPackages`, you will need to change it to `pkgs.xfce4-whiskermenu-plugin`). The `xfce` scope will be removed in NixOS 26.11. diff --git a/pkgs/development/web/nodejs/corepack.nix b/pkgs/development/web/nodejs/corepack.nix index d96f3bad0e215..a94d1fa207295 100644 --- a/pkgs/development/web/nodejs/corepack.nix +++ b/pkgs/development/web/nodejs/corepack.nix @@ -8,7 +8,8 @@ stdenv.mkDerivation { pname = "corepack-nodejs"; inherit (nodejs) version; - nativeBuildInputs = [ nodejs ]; + nativeBuildInputs = [ nodejs.corepack ]; + buildInputs = [ nodejs ]; dontUnpack = true; diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix index 3f270cf80c82b..100335d6e7dcc 100644 --- a/pkgs/development/web/nodejs/nodejs.nix +++ b/pkgs/development/web/nodejs/nodejs.nix @@ -173,6 +173,8 @@ let builtins.attrNames sharedLibDeps ); + bundlesCorepack = !lib.versionAtLeast version "25.0.0"; + # Currently stdenv sets CC/LD/AR/etc environment variables to program names # instead of absolute paths. If we add cctools to nativeBuildInputs, that # would shadow stdenv’s bintools and potentially break other parts of the @@ -275,6 +277,7 @@ let "libv8" "npm" ] + ++ lib.optional bundlesCorepack "corepack" ++ lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ "dev" ]; setOutputFlags = false; moveToDev = false; @@ -353,6 +356,7 @@ let postPatch = '' substituteInPlace tools/install.py \ + --replace-fail ' corepack_files(options, action)' " oip=options.install_path;options.install_path='$corepack';corepack_files(options, action);options.install_path=oip" \ --replace-fail ' npm_files(options, action)' " oip=options.install_path;options.install_path='$npm';npm_files(options, action);options.install_path=oip" '' + lib.optionalString stdenv.hostPlatform.isDarwin '' @@ -505,21 +509,29 @@ let outputChecks = { out = { disallowedReferences = [ + "libv8" "npm" + ] + ++ lib.optional bundlesCorepack "corepack"; + }; + corepack = { + disallowedReferences = [ "libv8" + "npm" ]; }; libv8 = { disallowedReferences = [ "out" "npm" - ]; + ] + ++ lib.optional bundlesCorepack "corepack"; }; npm = { disallowedReferences = [ - "out" "libv8" - ]; + ] + ++ lib.optional bundlesCorepack "corepack"; }; }; @@ -560,8 +572,6 @@ let '' + '' - HOST_PATH=$out/bin patchShebangs --host $out - ${lib.optionalString canExecute '' $out/bin/node --completion-bash > node.bash installShellCompletion node.bash @@ -609,6 +619,8 @@ let ''; postFixup = '' + HOST_PATH=$out/bin patchShebangs --host $out ${lib.optionalString bundlesCorepack "$corepack"} $npm + for dir in "$npm/lib/node_modules/npm/man/"*; do mkdir -p $npm/share/man/$(basename "$dir") for page in "$dir"/*; do diff --git a/pkgs/development/web/nodejs/symlink.nix b/pkgs/development/web/nodejs/symlink.nix new file mode 100644 index 0000000000000..87bbdbec63142 --- /dev/null +++ b/pkgs/development/web/nodejs/symlink.nix @@ -0,0 +1,14 @@ +{ + lib, + nodejs-slim, + symlinkJoin, +}: +symlinkJoin { + pname = "nodejs"; + inherit (nodejs-slim) version passthru meta; + paths = [ + nodejs-slim + nodejs-slim.npm + ] + ++ lib.optional (builtins.hasAttr "corepack" nodejs-slim) nodejs-slim.corepack; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 549d35401ce65..ac5e33c409cb9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2876,47 +2876,19 @@ with pkgs; nodejs-slim = nodejs-slim_24; nodejs-slim_20 = callPackage ../development/web/nodejs/v20.nix { }; - nodejs_20 = symlinkJoin { - pname = "nodejs"; - inherit (nodejs-slim_20) version passthru meta; - paths = [ - nodejs-slim_20 - nodejs-slim_20.npm - ]; - }; + nodejs_20 = callPackage ../development/web/nodejs/symlink.nix { nodejs-slim = nodejs-slim_20; }; corepack_20 = callPackage ../development/web/nodejs/corepack.nix { nodejs = nodejs-slim_20; }; nodejs-slim_22 = callPackage ../development/web/nodejs/v22.nix { }; - nodejs_22 = symlinkJoin { - pname = "nodejs"; - inherit (nodejs-slim_22) version passthru meta; - paths = [ - nodejs-slim_22 - nodejs-slim_22.npm - ]; - }; + nodejs_22 = callPackage ../development/web/nodejs/symlink.nix { nodejs-slim = nodejs-slim_22; }; corepack_22 = callPackage ../development/web/nodejs/corepack.nix { nodejs = nodejs-slim_22; }; nodejs-slim_24 = callPackage ../development/web/nodejs/v24.nix { }; - nodejs_24 = symlinkJoin { - pname = "nodejs"; - inherit (nodejs-slim_24) version passthru meta; - paths = [ - nodejs-slim_24 - nodejs-slim_24.npm - ]; - }; + nodejs_24 = callPackage ../development/web/nodejs/symlink.nix { nodejs-slim = nodejs-slim_24; }; corepack_24 = callPackage ../development/web/nodejs/corepack.nix { nodejs = nodejs-slim_24; }; nodejs-slim_25 = callPackage ../development/web/nodejs/v25.nix { }; - nodejs_25 = symlinkJoin { - pname = "nodejs"; - inherit (nodejs-slim_25) version passthru meta; - paths = [ - nodejs-slim_25 - nodejs-slim_25.npm - ]; - }; + nodejs_25 = callPackage ../development/web/nodejs/symlink.nix { nodejs-slim = nodejs-slim_25; }; # Update this when adding the newest nodejs major version! nodejs_latest = nodejs_25;