summary refs log tree commit diff
path: root/pkgs/development/web
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2013-05-28 18:38:16 -0400
committerShea Levy <shea@shealevy.com>2013-05-28 18:38:22 -0400
commit5ddae355961d890055d164acd5c883338716ccc1 (patch)
treeeef5177e545b95562f37c0405a5e4f907882bf32 /pkgs/development/web
parent9e012056593274f80a15c09c76b6d7a2d78746d2 (diff)
downloadnixpkgs-5ddae355961d890055d164acd5c883338716ccc1.tar
nixpkgs-5ddae355961d890055d164acd5c883338716ccc1.tar.gz
nixpkgs-5ddae355961d890055d164acd5c883338716ccc1.tar.bz2
nixpkgs-5ddae355961d890055d164acd5c883338716ccc1.tar.lz
nixpkgs-5ddae355961d890055d164acd5c883338716ccc1.tar.xz
nixpkgs-5ddae355961d890055d164acd5c883338716ccc1.tar.zst
nixpkgs-5ddae355961d890055d164acd5c883338716ccc1.zip
Get node.js building on darwin
Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'pkgs/development/web')
-rw-r--r--pkgs/development/web/nodejs/default.nix18
-rw-r--r--pkgs/development/web/nodejs/no-xcode.patch78
2 files changed, 93 insertions, 3 deletions
diff --git a/pkgs/development/web/nodejs/default.nix b/pkgs/development/web/nodejs/default.nix
index f3025c97f16..064284da1f5 100644
--- a/pkgs/development/web/nodejs/default.nix
+++ b/pkgs/development/web/nodejs/default.nix
@@ -1,6 +1,11 @@
-{ stdenv, fetchurl, openssl, python, zlib, v8, utillinux, http_parser, c-ares }:
+{ stdenv, fetchurl, openssl, python, zlib, v8, utillinux, http_parser, c-ares, pkgconfig, runCommand }:
 
 let
+  dtrace = runCommand "dtrace-native" {} ''
+    mkdir -p $out/bin
+    ln -sv /usr/sbin/dtrace $out/bin
+  '';
+
   version = "0.10.8";
 
   # !!! Should we also do shared libuv?
@@ -16,7 +21,7 @@ let
     "--shared-${name}-libpath=${builtins.getAttr name deps}/lib"
   ];
 
-  inherit (stdenv.lib) concatMap optional maintainers licenses platforms;
+  inherit (stdenv.lib) concatMap optional optionals maintainers licenses platforms;
 in stdenv.mkDerivation {
   name = "nodejs-${version}";
 
@@ -31,8 +36,15 @@ in stdenv.mkDerivation {
     sed -e 's|^#!/usr/bin/env python$|#!${python}/bin/python|g' -i configure
   '';
 
+  patches = if stdenv.isDarwin then [ ./no-xcode.patch ] else null;
+
+  postPatch = if stdenv.isDarwin then ''
+    (cd tools/gyp; patch -Np1 -i ${../../python-modules/gyp/no-darwin-cflags.patch})
+  '' else null;
+
   buildInputs = [ python ]
-    ++ optional stdenv.isLinux utillinux;
+    ++ (optional stdenv.isLinux utillinux)
+    ++ optionals stdenv.isDarwin [ pkgconfig openssl dtrace ];
   setupHook = ./setup-hook.sh;
 
   meta = {
diff --git a/pkgs/development/web/nodejs/no-xcode.patch b/pkgs/development/web/nodejs/no-xcode.patch
new file mode 100644
index 00000000000..47a37bfaf3c
--- /dev/null
+++ b/pkgs/development/web/nodejs/no-xcode.patch
@@ -0,0 +1,78 @@
+diff --git a/tools/gyp/pylib/gyp/xcode_emulation.py b/tools/gyp/pylib/gyp/xcode_emulation.py
+index 806f92b..5256856 100644
+--- a/tools/gyp/pylib/gyp/xcode_emulation.py
++++ b/tools/gyp/pylib/gyp/xcode_emulation.py
+@@ -224,8 +224,7 @@ class XcodeSettings(object):
+ 
+   def _GetSdkVersionInfoItem(self, sdk, infoitem):
+     job = subprocess.Popen(['xcodebuild', '-version', '-sdk', sdk, infoitem],
+-                           stdout=subprocess.PIPE,
+-                           stderr=subprocess.STDOUT)
++                           stdout=subprocess.PIPE)
+     out = job.communicate()[0]
+     if job.returncode != 0:
+       sys.stderr.write(out + '\n')
+@@ -234,9 +233,17 @@ class XcodeSettings(object):
+ 
+   def _SdkPath(self):
+     sdk_root = self.GetPerTargetSetting('SDKROOT', default='macosx')
++    if sdk_root.startswith('/'):
++      return sdk_root
+     if sdk_root not in XcodeSettings._sdk_path_cache:
+-      XcodeSettings._sdk_path_cache[sdk_root] = self._GetSdkVersionInfoItem(
+-          sdk_root, 'Path')
++      try:
++        XcodeSettings._sdk_path_cache[sdk_root] = self._GetSdkVersionInfoItem(
++            sdk_root, 'Path')
++      except:
++        # if this fails it's because xcodebuild failed, which means
++        # the user is probably on a CLT-only system, where there
++        # is no valid SDK root
++        XcodeSettings._sdk_path_cache[sdk_root] = None
+     return XcodeSettings._sdk_path_cache[sdk_root]
+ 
+   def _AppendPlatformVersionMinFlags(self, lst):
+@@ -339,10 +346,11 @@ class XcodeSettings(object):
+ 
+     cflags += self._Settings().get('WARNING_CFLAGS', [])
+ 
+-    config = self.spec['configurations'][self.configname]
+-    framework_dirs = config.get('mac_framework_dirs', [])
+-    for directory in framework_dirs:
+-      cflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
++    if 'SDKROOT' in self._Settings():
++      config = self.spec['configurations'][self.configname]
++      framework_dirs = config.get('mac_framework_dirs', [])
++      for directory in framework_dirs:
++        cflags.append('-F' + directory.replace('$(SDKROOT)', sdk_root))
+ 
+     self.configname = None
+     return cflags
+@@ -572,10 +580,11 @@ class XcodeSettings(object):
+     for rpath in self._Settings().get('LD_RUNPATH_SEARCH_PATHS', []):
+       ldflags.append('-Wl,-rpath,' + rpath)
+ 
+-    config = self.spec['configurations'][self.configname]
+-    framework_dirs = config.get('mac_framework_dirs', [])
+-    for directory in framework_dirs:
+-      ldflags.append('-F' + directory.replace('$(SDKROOT)', self._SdkPath()))
++    if 'SDKROOT' in self._Settings():
++      config = self.spec['configurations'][self.configname]
++      framework_dirs = config.get('mac_framework_dirs', [])
++      for directory in framework_dirs:
++        ldflags.append('-F' + directory.replace('$(SDKROOT)', self._SdkPath()))
+ 
+     self.configname = None
+     return ldflags
+@@ -700,7 +709,10 @@ class XcodeSettings(object):
+         l = '-l' + m.group(1)
+       else:
+         l = library
+-    return l.replace('$(SDKROOT)', self._SdkPath())
++    if self._SdkPath():
++      return l.replace('$(SDKROOT)', self._SdkPath())
++    else:
++      return l
+ 
+   def AdjustLibraries(self, libraries):
+     """Transforms entries like 'Cocoa.framework' in libraries into entries like