2020-04-07 12:45:55 +01:00
|
|
|
{ stdenv, fetchurl, openssl, python, zlib, libuv, utillinux, http-parser
|
2017-11-01 00:25:13 +00:00
|
|
|
, pkgconfig, which
|
2018-02-18 14:19:01 +00:00
|
|
|
# Updater dependencies
|
2019-02-28 06:33:17 +00:00
|
|
|
, writeScript, coreutils, gnugrep, jq, curl, common-updater-scripts, nix, runtimeShell
|
2018-02-18 14:19:01 +00:00
|
|
|
, gnupg
|
2018-08-15 23:35:56 +01:00
|
|
|
, darwin, xcbuild
|
2019-06-02 01:14:59 +01:00
|
|
|
, procps, icu
|
2016-04-25 15:10:10 +01:00
|
|
|
}:
|
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
with stdenv.lib;
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2018-08-15 23:35:56 +01:00
|
|
|
{ enableNpm ? true, version, sha256, patches ? [] } @args:
|
2017-11-01 00:25:13 +00:00
|
|
|
|
2016-04-25 15:10:10 +01:00
|
|
|
let
|
2016-11-02 16:46:01 +00:00
|
|
|
inherit (darwin.apple_sdk.frameworks) CoreServices ApplicationServices;
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2018-10-23 20:22:50 +01:00
|
|
|
majorVersion = versions.major version;
|
|
|
|
minorVersion = versions.minor version;
|
|
|
|
|
2017-11-01 00:25:13 +00:00
|
|
|
baseName = if enableNpm then "nodejs" else "nodejs-slim";
|
|
|
|
|
2018-10-23 20:22:50 +01:00
|
|
|
useSharedHttpParser = !stdenv.isDarwin && versionOlder "${majorVersion}.${minorVersion}" "11.4";
|
|
|
|
|
|
|
|
sharedLibDeps = { inherit openssl zlib libuv; } // (optionalAttrs useSharedHttpParser { inherit http-parser; });
|
2016-11-02 16:46:01 +00:00
|
|
|
|
|
|
|
sharedConfigureFlags = concatMap (name: [
|
2016-04-25 15:10:10 +01:00
|
|
|
"--shared-${name}"
|
2016-11-02 16:46:01 +00:00
|
|
|
"--shared-${name}-libpath=${getLib sharedLibDeps.${name}}/lib"
|
2016-11-02 16:49:19 +00:00
|
|
|
/** Closure notes: we explicitly avoid specifying --shared-*-includes,
|
|
|
|
* as that would put the paths into bin/nodejs.
|
|
|
|
* Including pkgconfig in build inputs would also have the same effect!
|
|
|
|
*/
|
2019-06-02 01:14:59 +01:00
|
|
|
]) (builtins.attrNames sharedLibDeps) ++ [
|
|
|
|
"--with-intl=system-icu"
|
|
|
|
];
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2018-02-27 13:26:16 +00:00
|
|
|
copyLibHeaders =
|
|
|
|
map
|
|
|
|
(name: "${getDev sharedLibDeps.${name}}/include/*")
|
|
|
|
(builtins.attrNames sharedLibDeps);
|
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
extraConfigFlags = optionals (!enableNpm) [ "--without-npm" ];
|
|
|
|
in
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2017-11-01 00:25:13 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
name = "${baseName}-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2018-09-11 04:28:05 +01:00
|
|
|
url = "https://nodejs.org/dist/v${version}/node-v${version}.tar.xz";
|
2017-11-01 00:25:13 +00:00
|
|
|
inherit sha256;
|
|
|
|
};
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
buildInputs = optionals stdenv.isDarwin [ CoreServices ApplicationServices ]
|
2019-03-16 15:43:20 +00:00
|
|
|
++ [ zlib libuv openssl http-parser icu ];
|
2018-08-15 23:35:56 +01:00
|
|
|
|
2020-04-07 12:45:55 +01:00
|
|
|
nativeBuildInputs = [ which utillinux pkgconfig python ]
|
2019-06-02 01:14:59 +01:00
|
|
|
++ optionals stdenv.isDarwin [ xcbuild ];
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2019-03-16 15:43:20 +00:00
|
|
|
configureFlags = let
|
|
|
|
isCross = stdenv.hostPlatform != stdenv.buildPlatform;
|
|
|
|
host = stdenv.hostPlatform.platform;
|
2020-02-05 18:21:35 +00:00
|
|
|
isAarch32 = stdenv.hostPlatform.isAarch32;
|
2019-03-16 15:43:20 +00:00
|
|
|
in sharedConfigureFlags ++ [
|
|
|
|
"--without-dtrace"
|
|
|
|
] ++ (optionals isCross [
|
|
|
|
"--cross-compiling"
|
|
|
|
"--without-intl"
|
|
|
|
"--without-snapshot"
|
2020-02-05 18:21:35 +00:00
|
|
|
]) ++ (optionals (isCross && isAarch32 && hasAttr "fpu" host.gcc) [
|
2019-03-16 15:43:20 +00:00
|
|
|
"--with-arm-fpu=${host.gcc.fpu}"
|
2020-02-05 18:21:35 +00:00
|
|
|
]) ++ (optionals (isCross && isAarch32 && hasAttr "float-abi" host.gcc) [
|
2019-03-16 15:43:20 +00:00
|
|
|
"--with-arm-float-abi=${host.gcc.float-abi}"
|
2020-02-05 18:21:35 +00:00
|
|
|
]) ++ (optionals (isCross && isAarch32) [
|
2019-03-16 15:43:20 +00:00
|
|
|
"--dest-cpu=arm"
|
|
|
|
]) ++ extraConfigFlags;
|
|
|
|
|
|
|
|
configurePlatforms = [];
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
dontDisableStatic = true;
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
enableParallelBuilding = true;
|
2016-08-08 21:14:01 +01:00
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
passthru.interpreterName = "nodejs";
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2018-02-18 14:06:12 +00:00
|
|
|
pos = builtins.unsafeGetAttrPos "version" args;
|
|
|
|
|
2017-11-01 00:25:13 +00:00
|
|
|
inherit patches;
|
2016-11-02 16:46:01 +00:00
|
|
|
|
2018-08-08 22:17:04 +01:00
|
|
|
postPatch = ''
|
2016-11-02 16:46:01 +00:00
|
|
|
patchShebangs .
|
2018-08-08 22:17:04 +01:00
|
|
|
|
|
|
|
# fix tests
|
|
|
|
for a in test/parallel/test-child-process-env.js \
|
|
|
|
test/parallel/test-child-process-exec-env.js \
|
|
|
|
test/parallel/test-child-process-default-options.js \
|
|
|
|
test/fixtures/syntax/good_syntax_shebang.js \
|
|
|
|
test/fixtures/syntax/bad_syntax_shebang.js ; do
|
|
|
|
substituteInPlace $a \
|
|
|
|
--replace "/usr/bin/env" "${coreutils}/bin/env"
|
|
|
|
done
|
|
|
|
'' + optionalString stdenv.isDarwin ''
|
2019-03-15 19:23:50 +00:00
|
|
|
sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' tools/gyp/pylib/gyp/xcode_emulation.py
|
2018-08-08 22:17:04 +01:00
|
|
|
sed -i -e "s|tr1/type_traits|type_traits|g" \
|
|
|
|
-e "s|std::tr1|std|" src/util.h
|
2016-11-02 16:46:01 +00:00
|
|
|
'';
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2018-08-08 22:17:04 +01:00
|
|
|
checkInputs = [ procps ];
|
|
|
|
doCheck = false; # fails 4 out of 1453 tests
|
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
postInstall = ''
|
|
|
|
PATH=$out/bin:$PATH patchShebangs $out
|
2016-12-11 13:57:49 +00:00
|
|
|
|
2019-03-16 15:43:20 +00:00
|
|
|
${optionalString (enableNpm && stdenv.hostPlatform == stdenv.buildPlatform) ''
|
2016-12-11 13:57:49 +00:00
|
|
|
mkdir -p $out/share/bash-completion/completions/
|
|
|
|
$out/bin/npm completion > $out/share/bash-completion/completions/npm
|
2019-02-23 01:57:29 +00:00
|
|
|
for dir in "$out/lib/node_modules/npm/man/"*; do
|
|
|
|
mkdir -p $out/share/man/$(basename "$dir")
|
|
|
|
for page in "$dir"/*; do
|
|
|
|
ln -rs $page $out/share/man/$(basename "$dir")
|
|
|
|
done
|
|
|
|
done
|
2016-12-11 13:57:49 +00:00
|
|
|
''}
|
2018-02-27 13:26:16 +00:00
|
|
|
|
|
|
|
# install the missing headers for node-gyp
|
|
|
|
cp -r ${concatStringsSep " " copyLibHeaders} $out/include/node
|
2019-03-15 19:23:50 +00:00
|
|
|
'' + optionalString (stdenv.isDarwin && enableNpm) ''
|
|
|
|
sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' $out/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py
|
2016-11-02 16:46:01 +00:00
|
|
|
'';
|
2016-04-25 15:10:10 +01:00
|
|
|
|
2018-02-18 14:19:01 +00:00
|
|
|
passthru.updateScript = import ./update.nix {
|
2019-06-18 12:08:32 +01:00
|
|
|
inherit writeScript coreutils gnugrep jq curl common-updater-scripts gnupg nix runtimeShell;
|
2018-02-18 14:19:01 +00:00
|
|
|
inherit (stdenv) lib;
|
2018-10-23 20:22:50 +01:00
|
|
|
inherit majorVersion;
|
2018-02-18 14:19:01 +00:00
|
|
|
};
|
|
|
|
|
2016-11-02 16:46:01 +00:00
|
|
|
meta = {
|
|
|
|
description = "Event-driven I/O framework for the V8 JavaScript engine";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://nodejs.org";
|
2016-11-02 16:46:01 +00:00
|
|
|
license = licenses.mit;
|
2020-07-01 00:17:35 +01:00
|
|
|
maintainers = with maintainers; [ goibhniu gilligan cko marsam ];
|
2016-11-02 16:46:01 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
};
|
2016-11-18 12:02:01 +00:00
|
|
|
|
2020-04-07 12:45:55 +01:00
|
|
|
passthru.python = python; # to ensure nodeEnv uses the same version
|
2016-04-25 15:10:10 +01:00
|
|
|
}
|