2017-11-01 01:25:13 +01:00
|
|
|
{ stdenv, fetchurl, openssl, python2, zlib, libuv, utillinux, http-parser
|
|
|
|
, pkgconfig, which
|
2018-02-18 15:19:01 +01:00
|
|
|
# Updater dependencies
|
|
|
|
, writeScript, coreutils, gnugrep, jq, curl, common-updater-scripts, nix
|
|
|
|
, gnupg
|
2018-08-16 00:35:56 +02:00
|
|
|
, darwin, xcbuild
|
2018-08-08 23:17:04 +02:00
|
|
|
, procps
|
2016-04-25 16:10:10 +02:00
|
|
|
}:
|
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
with stdenv.lib;
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2018-08-16 00:35:56 +02:00
|
|
|
{ enableNpm ? true, version, sha256, patches ? [] } @args:
|
2017-11-01 01:25:13 +01:00
|
|
|
|
2016-04-25 16:10:10 +02:00
|
|
|
let
|
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
inherit (darwin.apple_sdk.frameworks) CoreServices ApplicationServices;
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2017-11-01 01:25:13 +01:00
|
|
|
baseName = if enableNpm then "nodejs" else "nodejs-slim";
|
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
sharedLibDeps = { inherit openssl zlib libuv; } // (optionalAttrs (!stdenv.isDarwin) { inherit http-parser; });
|
|
|
|
|
|
|
|
sharedConfigureFlags = concatMap (name: [
|
2016-04-25 16:10:10 +02:00
|
|
|
"--shared-${name}"
|
2016-11-02 17:46:01 +01:00
|
|
|
"--shared-${name}-libpath=${getLib sharedLibDeps.${name}}/lib"
|
2016-11-02 17:49:19 +01: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!
|
|
|
|
*/
|
2016-11-02 17:46:01 +01:00
|
|
|
]) (builtins.attrNames sharedLibDeps);
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2018-02-27 14:26:16 +01:00
|
|
|
copyLibHeaders =
|
|
|
|
map
|
|
|
|
(name: "${getDev sharedLibDeps.${name}}/include/*")
|
|
|
|
(builtins.attrNames sharedLibDeps);
|
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
extraConfigFlags = optionals (!enableNpm) [ "--without-npm" ];
|
|
|
|
in
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2017-11-01 01:25:13 +01:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
name = "${baseName}-${version}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
2018-09-11 05:28:05 +02:00
|
|
|
url = "https://nodejs.org/dist/v${version}/node-v${version}.tar.xz";
|
2017-11-01 01:25:13 +01:00
|
|
|
inherit sha256;
|
|
|
|
};
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
buildInputs = optionals stdenv.isDarwin [ CoreServices ApplicationServices ]
|
2018-08-16 00:35:56 +02:00
|
|
|
++ [ python2 zlib libuv openssl http-parser ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ which utillinux ]
|
|
|
|
++ optionals stdenv.isDarwin [ pkgconfig xcbuild ];
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
configureFlags = sharedConfigureFlags ++ [ "--without-dtrace" ] ++ extraConfigFlags;
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
dontDisableStatic = true;
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
enableParallelBuilding = true;
|
2016-08-08 22:14:01 +02:00
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
passthru.interpreterName = "nodejs";
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
2018-02-18 15:06:12 +01:00
|
|
|
pos = builtins.unsafeGetAttrPos "version" args;
|
|
|
|
|
2017-11-01 01:25:13 +01:00
|
|
|
inherit patches;
|
2016-11-02 17:46:01 +01:00
|
|
|
|
2018-08-08 23:17:04 +02:00
|
|
|
postPatch = ''
|
2016-11-02 17:46:01 +01:00
|
|
|
patchShebangs .
|
|
|
|
sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' tools/gyp/pylib/gyp/xcode_emulation.py
|
2018-08-08 23:17:04 +02: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 ''
|
|
|
|
sed -i -e "s|tr1/type_traits|type_traits|g" \
|
|
|
|
-e "s|std::tr1|std|" src/util.h
|
2016-11-02 17:46:01 +01:00
|
|
|
'';
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2018-08-08 23:17:04 +02:00
|
|
|
checkInputs = [ procps ];
|
|
|
|
doCheck = false; # fails 4 out of 1453 tests
|
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
postInstall = ''
|
2016-11-10 03:19:47 +01:00
|
|
|
paxmark m $out/bin/node
|
2016-11-02 17:46:01 +01:00
|
|
|
PATH=$out/bin:$PATH patchShebangs $out
|
2016-12-11 14:57:49 +01:00
|
|
|
|
2017-11-01 01:25:13 +01:00
|
|
|
${optionalString enableNpm ''
|
2016-12-11 14:57:49 +01:00
|
|
|
mkdir -p $out/share/bash-completion/completions/
|
|
|
|
$out/bin/npm completion > $out/share/bash-completion/completions/npm
|
|
|
|
''}
|
2018-02-27 14:26:16 +01:00
|
|
|
|
|
|
|
# install the missing headers for node-gyp
|
|
|
|
cp -r ${concatStringsSep " " copyLibHeaders} $out/include/node
|
2016-11-02 17:46:01 +01:00
|
|
|
'';
|
2016-04-25 16:10:10 +02:00
|
|
|
|
2018-02-18 15:19:01 +01:00
|
|
|
passthru.updateScript = import ./update.nix {
|
|
|
|
inherit writeScript coreutils gnugrep jq curl common-updater-scripts gnupg nix;
|
|
|
|
inherit (stdenv) lib;
|
|
|
|
majorVersion = with stdenv.lib; elemAt (splitString "." version) 0;
|
|
|
|
};
|
|
|
|
|
2016-11-02 17:46:01 +01:00
|
|
|
meta = {
|
|
|
|
description = "Event-driven I/O framework for the V8 JavaScript engine";
|
2017-08-22 20:50:04 +02:00
|
|
|
homepage = https://nodejs.org;
|
2016-11-02 17:46:01 +01:00
|
|
|
license = licenses.mit;
|
2018-02-27 03:09:32 +01:00
|
|
|
maintainers = with maintainers; [ goibhniu gilligan cko ];
|
2016-11-02 17:46:01 +01:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
};
|
2016-11-18 13:02:01 +01:00
|
|
|
|
|
|
|
passthru.python = python2; # to ensure nodeEnv uses the same version
|
2016-04-25 16:10:10 +02:00
|
|
|
}
|