nixpkgs/pkgs/development/web/nodejs/nodejs.nix

78 lines
2.3 KiB
Nix
Raw Normal View History

2016-10-18 08:08:28 +00:00
{ stdenv, fetchurl, openssl, python2, zlib, libuv, v8, utillinux, http-parser
, pkgconfig, runCommand, which, libtool, fetchpatch
, callPackage
, darwin ? null
, enableNpm ? true
2016-04-25 14:10:10 +00:00
}:
with stdenv.lib;
2016-04-25 14:10:10 +00:00
let
inherit (darwin.apple_sdk.frameworks) CoreServices ApplicationServices;
2016-04-25 14:10:10 +00:00
sharedLibDeps = { inherit openssl zlib libuv; } // (optionalAttrs (!stdenv.isDarwin) { inherit http-parser; });
sharedConfigureFlags = concatMap (name: [
2016-04-25 14:10:10 +00:00
"--shared-${name}"
"--shared-${name}-libpath=${getLib sharedLibDeps.${name}}/lib"
/** 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!
*/
]) (builtins.attrNames sharedLibDeps);
2016-04-25 14:10:10 +00:00
extraConfigFlags = optionals (!enableNpm) [ "--without-npm" ];
in
2016-04-25 14:10:10 +00:00
rec {
2016-04-25 14:10:10 +00:00
buildInputs = optionals stdenv.isDarwin [ CoreServices ApplicationServices ]
++ [ python2 which zlib libuv openssl ]
++ optionals stdenv.isLinux [ utillinux http-parser ]
++ optionals stdenv.isDarwin [ pkgconfig libtool ];
2016-04-25 14:10:10 +00:00
configureFlags = sharedConfigureFlags ++ [ "--without-dtrace" ] ++ extraConfigFlags;
2016-04-25 14:10:10 +00:00
dontDisableStatic = true;
2016-04-25 14:10:10 +00:00
enableParallelBuilding = true;
passthru.interpreterName = "nodejs";
2016-04-25 14:10:10 +00:00
setupHook = ./setup-hook.sh;
patches = optionals stdenv.isDarwin [ ./no-xcode.patch ];
preBuild = optionalString stdenv.isDarwin ''
sed -i -e "s|tr1/type_traits|type_traits|g" \
-e "s|std::tr1|std|" src/util.h
'';
prePatch = ''
patchShebangs .
sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' tools/gyp/pylib/gyp/xcode_emulation.py
'';
2016-04-25 14:10:10 +00:00
postInstall = ''
paxmark m $out/bin/node
PATH=$out/bin:$PATH patchShebangs $out
2016-12-11 13:57:49 +00:00
${optionalString enableNpm ''
mkdir -p $out/share/bash-completion/completions/
$out/bin/npm completion > $out/share/bash-completion/completions/npm
''}
'';
2016-04-25 14:10:10 +00:00
meta = {
description = "Event-driven I/O framework for the V8 JavaScript engine";
homepage = http://nodejs.org;
license = licenses.mit;
maintainers = with maintainers; [ goibhniu havvy gilligan cko ];
platforms = platforms.linux ++ platforms.darwin;
};
passthru.python = python2; # to ensure nodeEnv uses the same version
2016-04-25 14:10:10 +00:00
}