@@ -0,0 +1,64 @@
1+{ stdenv, fetchurl, openssl, python, zlib, v8, utillinux, http-parser, c-ares
2+, pkgconfig, runCommand, which
3+}:
4+
5+let
6+ dtrace = runCommand "dtrace-native" {} ''
7+ mkdir -p $out/bin
8+ ln -sv /usr/sbin/dtrace $out/bin
9+ '';
10+
11+ version = "0.10.38";
12+
13+ # !!! Should we also do shared libuv?
14+ deps = {
15+ inherit openssl zlib;
16+
17+ # disabled system v8 because v8 3.14 no longer receives security fixes
18+ # we fall back to nodejs' internal v8 copy which receives backports for now
19+ # inherit v8
20+ } // (stdenv.lib.optionalAttrs (!stdenv.isDarwin) {
21+ inherit http-parser;
22+ })
23+ // ({ cares = c-ares; });
24+
25+ sharedConfigureFlags = name: [
26+ "--shared-${name}"
27+ "--shared-${name}-includes=${builtins.getAttr name deps}/include"
28+ "--shared-${name}-libpath=${builtins.getAttr name deps}/lib"
29+ ];
30+
31+ inherit (stdenv.lib) concatMap optional optionals maintainers licenses platforms;
32+in stdenv.mkDerivation {
33+ name = "nodejs-${version}";
34+
35+ src = fetchurl {
36+ url = "http://nodejs.org/dist/v${version}/node-v${version}.tar.gz";
37+ sha256 = "12xpa9jzry5g0j41908498qqs8v0q6miqkv6mggyzas8bvnshgai";
38+ };
39+
40+ configureFlags = concatMap sharedConfigureFlags (builtins.attrNames deps);
41+
42+ prePatch = ''
43+ sed -e 's|^#!/usr/bin/env python$|#!${python}/bin/python|g' -i configure
44+ '';
45+
46+ patches = if stdenv.isDarwin then [ ./no-xcode.patch ] else null;
47+
48+ postPatch = if stdenv.isDarwin then ''
49+ (cd tools/gyp; patch -Np1 -i ${../../python-modules/gyp/no-darwin-cflags.patch})
50+ '' else null;
51+
52+ buildInputs = [ python which ]
53+ ++ (optional stdenv.isLinux utillinux)
54+ ++ optionals stdenv.isDarwin [ pkgconfig openssl dtrace ];
55+ setupHook = ./setup-hook.sh;
56+
57+ meta = {
58+ description = "Event-driven I/O framework for the V8 JavaScript engine";
59+ homepage = http://nodejs.org;
60+ license = licenses.mit;
61+ maintainers = [ maintainers.goibhniu maintainers.shlevy ];
62+ platforms = platforms.linux ++ platforms.darwin;
63+ };
64+}