Merge pull request #173602 from wmertens/nodejs18-backport-21.11

nodejs: backport all including v18
This commit is contained in:
Wout Mertens
2022-05-19 15:04:03 +02:00
committed by GitHub
6 changed files with 50 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
{ lib, stdenv, fetchurl, openssl, python, zlib, libuv, util-linux, http-parser
, pkg-config, which
, pkg-config, which, buildPackages
# for `.pkgs` attribute
, callPackage
# Updater dependencies
@@ -19,7 +19,7 @@ let
majorVersion = versions.major version;
minorVersion = versions.minor version;
baseName = if enableNpm then "nodejs" else "nodejs-slim";
pname = if enableNpm then "nodejs" else "nodejs-slim";
useSharedHttpParser = !stdenv.isDarwin && versionOlder "${majorVersion}.${minorVersion}" "11.4";
@@ -43,15 +43,17 @@ let
extraConfigFlags = optionals (!enableNpm) [ "--without-npm" ];
self = stdenv.mkDerivation {
inherit version;
name = "${baseName}-${version}";
inherit pname version;
src = fetchurl {
url = "https://nodejs.org/dist/v${version}/node-v${version}.tar.xz";
inherit sha256;
};
CC_host = "cc";
CXX_host = "c++";
depsBuildBuild = [ buildPackages.stdenv.cc openssl libuv zlib ];
buildInputs = optionals stdenv.isDarwin [ CoreServices ApplicationServices ]
++ [ zlib libuv openssl http-parser icu ];
@@ -71,12 +73,23 @@ let
"--cross-compiling"
"--without-intl"
"--without-snapshot"
"--dest-cpu=${let platform = stdenv.hostPlatform; in
if platform.isAarch32 then "arm"
else if platform.isAarch64 then "arm64"
else if platform.isMips32 && platform.isLittleEndian then "mipsel"
else if platform.isMips32 && !platform.isLittleEndian then "mips"
else if platform.isMips64 && platform.isLittleEndian then "mips64el"
else if platform.isPower && platform.is32bit then "ppc"
else if platform.isPower && platform.is64bit then "ppc64"
else if platform.isx86_64 then "x86_64"
else if platform.isx86_32 then "x86"
else if platform.isS390 && platform.is64bit then "s390x"
else if platform.isRiscV && platform.is64bit then "riscv64"
else throw "unsupported cpu ${stdenv.hostPlatform.uname.processor}"}"
]) ++ (optionals (isCross && isAarch32 && hasAttr "fpu" gcc) [
"--with-arm-fpu=${gcc.fpu}"
]) ++ (optionals (isCross && isAarch32 && hasAttr "float-abi" gcc) [
"--with-arm-float-abi=${gcc.float-abi}"
]) ++ (optionals (isCross && isAarch32) [
"--dest-cpu=arm"
]) ++ extraConfigFlags;
configurePlatforms = [];
@@ -123,7 +136,7 @@ let
${optionalString (enableNpm && stdenv.hostPlatform == stdenv.buildPlatform) ''
mkdir -p $out/share/bash-completion/completions/
$out/bin/npm completion > $out/share/bash-completion/completions/npm
HOME=$TMPDIR $out/bin/npm completion > $out/share/bash-completion/completions/npm
for dir in "$out/lib/node_modules/npm/man/"*; do
mkdir -p $out/share/man/$(basename "$dir")
for page in "$dir"/*; do
@@ -181,7 +194,7 @@ let
maintainers = with maintainers; [ goibhniu gilligan cko marsam ];
platforms = platforms.linux ++ platforms.darwin;
mainProgram = "node";
knownVulnerabilities = optional (versionOlder version "12") "This NodeJS release has reached its end of life. See https://nodejs.org/en/about/releases/.";
knownVulnerabilities = optional (versionOlder version "14") "This NodeJS release has reached its end of life. See https://nodejs.org/en/about/releases/.";
};
passthru.python = python; # to ensure nodeEnv uses the same version

View File

@@ -8,7 +8,7 @@ let
in
buildNodejs {
inherit enableNpm;
version = "12.22.11";
sha256 = "sha256-XoHaJv1bH4lxRIOrqmjj2jBFI+QzTHjEm/p6A+541vE=";
version = "12.22.12";
sha256 = "1whl0zi6fs9ay33bhcn2kh9xynran05iipahg1zzr6sv97wbfhmw";
patches = lib.optional stdenv.isDarwin ./bypass-xcodebuild.diff;
}

View File

@@ -7,7 +7,7 @@ let
in
buildNodejs {
inherit enableNpm;
version = "14.19.1";
sha256 = "sha256-4a4J3YYas5rwRIO7XA+lTd2CtrFVQ76aJ+pnBKi6ndk=";
version = "14.19.3";
sha256 = "sha256-XPRbHxrKd1I6zzYkDB1TqZknkHCncR6r8jNG+IsMyZQ=";
patches = lib.optional stdenv.isDarwin ./bypass-xcodebuild.diff;
}

View File

@@ -1,4 +1,4 @@
{ callPackage, fetchpatch, openssl, python3, enableNpm ? true }:
{ callPackage, openssl, python3, enableNpm ? true }:
let
buildNodejs = callPackage ./nodejs.nix {
@@ -8,15 +8,9 @@ let
in
buildNodejs {
inherit enableNpm;
version = "16.14.2";
sha256 = "sha256-6SLiFcxo61+U0z6KC2HiyGO3cxzIYAq5VdOCLakP+NE=";
version = "16.15.0";
sha256 = "sha256-oPgS78Q/eDIeygiVeWCkj15r+XAE1QWMjdOwPGRupPc=";
patches = [
./disable-darwin-v8-system-instrumentation.patch
# Fixes node incorrectly building vendored OpenSSL when we want system OpenSSL.
# https://github.com/nodejs/node/pull/40965
(fetchpatch {
url = "https://github.com/nodejs/node/commit/65119a89586b94b0dd46b45f6d315c9d9f4c9261.patch";
sha256 = "sha256-dihKYEdK68sQIsnfTRambJ2oZr0htROVbNZlFzSAL+I=";
})
];
}

View File

@@ -0,0 +1,15 @@
{ callPackage, python3, enableNpm ? true }:
let
buildNodejs = callPackage ./nodejs.nix {
python = python3;
};
in
buildNodejs {
inherit enableNpm;
version = "18.2.0";
sha256 = "sha256-IwWxXr9VR0dOkFtQAvm6mcfu7wHXOU3+bzhGzGvK1m0=";
patches = [
./disable-darwin-v8-system-instrumentation.patch
];
}

View File

@@ -7173,10 +7173,13 @@ with pkgs;
nodejs-slim-17_x = callPackage ../development/web/nodejs/v17.nix {
enableNpm = false;
};
nodejs-18_x = callPackage ../development/web/nodejs/v18.nix { };
nodejs-slim-18_x = callPackage ../development/web/nodejs/v18.nix {
enableNpm = false;
};
# Update this when adding the newest nodejs major version!
# Do not set to nodejs-17_x because it requires 10.13 SDK on Darwin
nodejs_latest = nodejs-16_x;
nodejs-slim_latest = nodejs-slim-16_x;
nodejs_latest = nodejs-18_x;
nodejs-slim_latest = nodejs-slim-18_x;
nodePackages_latest = dontRecurseIntoAttrs nodejs_latest.pkgs;