summary refs log tree commit diff
path: root/pkgs/development/web/nodejs
diff options
context:
space:
mode:
authorMathias Schreck <schreck.mathias@googlemail.com>2017-11-01 01:25:13 +0100
committerRobin Gloster <mail@glob.in>2017-11-02 10:58:45 +0100
commitccbcf15c8ee86bd1c2e4eae39d225fab63b376f5 (patch)
treeb0f9de6966baa7276a6b4316c1f5cb8c5568cc62 /pkgs/development/web/nodejs
parent9ac793f860622b40ac8856a89abec202abad51e3 (diff)
downloadnixpkgs-ccbcf15c8ee86bd1c2e4eae39d225fab63b376f5.tar
nixpkgs-ccbcf15c8ee86bd1c2e4eae39d225fab63b376f5.tar.gz
nixpkgs-ccbcf15c8ee86bd1c2e4eae39d225fab63b376f5.tar.bz2
nixpkgs-ccbcf15c8ee86bd1c2e4eae39d225fab63b376f5.tar.lz
nixpkgs-ccbcf15c8ee86bd1c2e4eae39d225fab63b376f5.tar.xz
nixpkgs-ccbcf15c8ee86bd1c2e4eae39d225fab63b376f5.tar.zst
nixpkgs-ccbcf15c8ee86bd1c2e4eae39d225fab63b376f5.zip
nodejs: refactor generic build function
This removes some duplicated and dead code across the different versions of
nodejs.
Diffstat (limited to 'pkgs/development/web/nodejs')
-rw-r--r--pkgs/development/web/nodejs/nodejs.nix29
-rw-r--r--pkgs/development/web/nodejs/v4.nix23
-rw-r--r--pkgs/development/web/nodejs/v6.nix22
-rw-r--r--pkgs/development/web/nodejs/v8.nix24
-rw-r--r--pkgs/development/web/nodejs/v9.nix24
5 files changed, 48 insertions, 74 deletions
diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix
index d7917c52c99..eafaf956ee0 100644
--- a/pkgs/development/web/nodejs/nodejs.nix
+++ b/pkgs/development/web/nodejs/nodejs.nix
@@ -1,16 +1,20 @@
-{ stdenv, fetchurl, openssl, python2, zlib, libuv, v8, utillinux, http-parser
-, pkgconfig, runCommand, which, libtool, fetchpatch
-, callPackage
+{ stdenv, fetchurl, openssl, python2, zlib, libuv, utillinux, http-parser
+, pkgconfig, which
 , darwin ? null
-, enableNpm ? true
 }:
 
 with stdenv.lib;
 
+{ enableNpm ? true, version, sha256, patches }:
+
 let
 
   inherit (darwin.apple_sdk.frameworks) CoreServices ApplicationServices;
 
+
+
+  baseName = if enableNpm then "nodejs" else "nodejs-slim";
+
   sharedLibDeps = { inherit openssl zlib libuv; } // (optionalAttrs (!stdenv.isDarwin) { inherit http-parser; });
 
   sharedConfigureFlags = concatMap (name: [
@@ -25,12 +29,20 @@ let
   extraConfigFlags = optionals (!enableNpm) [ "--without-npm" ];
 in
 
-  rec {
+  stdenv.mkDerivation {
+    inherit version;
+
+    name = "${baseName}-${version}";
+
+    src = fetchurl {
+      url = "http://nodejs.org/dist/v${version}/node-v${version}.tar.xz";
+      inherit sha256;
+    };
 
     buildInputs = optionals stdenv.isDarwin [ CoreServices ApplicationServices ]
     ++ [ python2 which zlib libuv openssl ]
     ++ optionals stdenv.isLinux [ utillinux http-parser ]
-    ++ optionals stdenv.isDarwin [ pkgconfig libtool ];
+    ++ optionals stdenv.isDarwin [ pkgconfig darwin.cctools ];
 
     configureFlags = sharedConfigureFlags ++ [ "--without-dtrace" ] ++ extraConfigFlags;
 
@@ -40,10 +52,9 @@ in
 
     passthru.interpreterName = "nodejs";
 
-
     setupHook = ./setup-hook.sh;
 
-    patches = optionals stdenv.isDarwin [ ./no-xcode.patch ];
+    inherit patches;
 
     preBuild = optionalString stdenv.isDarwin ''
       sed -i -e "s|tr1/type_traits|type_traits|g" \
@@ -59,7 +70,7 @@ in
       paxmark m $out/bin/node
       PATH=$out/bin:$PATH patchShebangs $out
 
-      ${optionalString enableNpm '' 
+      ${optionalString enableNpm ''
         mkdir -p $out/share/bash-completion/completions/
         $out/bin/npm completion > $out/share/bash-completion/completions/npm
       ''}
diff --git a/pkgs/development/web/nodejs/v4.nix b/pkgs/development/web/nodejs/v4.nix
index d3ad4d11e4c..08fd91aaf8d 100644
--- a/pkgs/development/web/nodejs/v4.nix
+++ b/pkgs/development/web/nodejs/v4.nix
@@ -1,20 +1,11 @@
-{ stdenv, fetchurl, openssl, python2, zlib, libuv, v8, utillinux, http-parser
-, pkgconfig, runCommand, which, libtool, fetchpatch
-, callPackage
-, darwin ? null
-, enableNpm ? true
-}@args:
+{ stdenv, callPackage, lib, enableNpm ? true }:
 
 let
-  nodejs = import ./nodejs.nix args;
-  baseName = if enableNpm then "nodejs" else "nodejs-slim";
+  buildNodejs = callPackage ./nodejs.nix {};
 in
-  stdenv.mkDerivation (nodejs // rec {
+  buildNodejs {
+    inherit enableNpm;
     version = "4.8.5";
-    name = "${baseName}-${version}";
-    src = fetchurl {
-      url = "http://nodejs.org/dist/v${version}/node-v${version}.tar.xz";
-      sha256 = "0lqdnnihmc2wpl1v1shj60i49wka2354b00a86k0xbjg5gyfx2m4";
-    };
-
-  })
+    sha256 = "0lqdnnihmc2wpl1v1shj60i49wka2354b00a86k0xbjg5gyfx2m4";
+    patches = lib.optionals stdenv.isDarwin [ ./no-xcode.patch ];
+  }
diff --git a/pkgs/development/web/nodejs/v6.nix b/pkgs/development/web/nodejs/v6.nix
index e516d9b99b6..c703377d5a0 100644
--- a/pkgs/development/web/nodejs/v6.nix
+++ b/pkgs/development/web/nodejs/v6.nix
@@ -1,19 +1,11 @@
-{ stdenv, fetchurl, openssl, python2, zlib, libuv, v8, utillinux, http-parser
-, pkgconfig, runCommand, which, libtool, fetchpatch
-, callPackage
-, darwin ? null
-, enableNpm ? true
-}@args:
+{ stdenv, callPackage, lib, enableNpm ? true }:
 
 let
-  nodejs = import ./nodejs.nix args;
-  baseName = if enableNpm then "nodejs" else "nodejs-slim";
+  buildNodejs = callPackage ./nodejs.nix {};
 in
-  stdenv.mkDerivation (nodejs // rec {
+  buildNodejs {
+    inherit enableNpm;
     version = "6.11.5";
-    name = "${baseName}-${version}";
-    src = fetchurl {
-      url = "https://nodejs.org/download/release/v${version}/node-v${version}.tar.xz";
-      sha256 = "1bwakrvy0if5spbymwpb05qwrb47xwzlnc42rapgp6b744ay8v8w";
-    };
-  })
+    sha256 = "1bwakrvy0if5spbymwpb05qwrb47xwzlnc42rapgp6b744ay8v8w";
+    patches = lib.optionals stdenv.isDarwin [ ./no-xcode.patch ];
+  }
diff --git a/pkgs/development/web/nodejs/v8.nix b/pkgs/development/web/nodejs/v8.nix
index c47a65bb4e1..1735d1cf9cf 100644
--- a/pkgs/development/web/nodejs/v8.nix
+++ b/pkgs/development/web/nodejs/v8.nix
@@ -1,21 +1,11 @@
-{ stdenv, fetchurl, openssl, python2, zlib, libuv, v8, utillinux, http-parser
-, pkgconfig, runCommand, which, libtool, fetchpatch
-, callPackage
-, darwin ? null
-, enableNpm ? true
-}@args:
+{ stdenv, callPackage, lib, enableNpm ? true }:
 
 let
-  nodejs = import ./nodejs.nix args;
-  baseName = if enableNpm then "nodejs" else "nodejs-slim";
+  buildNodejs = callPackage ./nodejs.nix {};
 in
-  stdenv.mkDerivation (nodejs // rec {
+  buildNodejs {
+    inherit enableNpm;
     version = "8.9.0";
-    name = "${baseName}-${version}";
-    src = fetchurl {
-      url = "https://nodejs.org/download/release/v${version}/node-v${version}.tar.xz";
-      sha256 = "128ir6rkdz1xj55hbflw0sh7snrrvjwgvxmgnka7cyhjkvw5i0mf";
-    };
-
-    patches = stdenv.lib.optionals stdenv.isDarwin [ ./no-xcode-v7.patch ];
-  })
+    sha256 = "128ir6rkdz1xj55hbflw0sh7snrrvjwgvxmgnka7cyhjkvw5i0mf";
+    patches = lib.optionals stdenv.isDarwin [ ./no-xcode-v7.patch ];
+  }
diff --git a/pkgs/development/web/nodejs/v9.nix b/pkgs/development/web/nodejs/v9.nix
index 7b99275eedc..aa51421253f 100644
--- a/pkgs/development/web/nodejs/v9.nix
+++ b/pkgs/development/web/nodejs/v9.nix
@@ -1,21 +1,11 @@
-{ stdenv, fetchurl, openssl, python2, zlib, libuv, v8, utillinux, http-parser
-, pkgconfig, runCommand, which, libtool, fetchpatch
-, callPackage
-, darwin ? null
-, enableNpm ? true
-}@args:
+{ stdenv, callPackage, lib, enableNpm ? true }:
 
 let
-  nodejs = import ./nodejs.nix args;
-  baseName = if enableNpm then "nodejs" else "nodejs-slim";
+  buildNodejs = callPackage ./nodejs.nix {};
 in
-  stdenv.mkDerivation (nodejs // rec {
+  buildNodejs {
+    inherit enableNpm;
     version = "9.0.0";
-    name = "${baseName}-${version}";
-    src = fetchurl {
-      url = "https://nodejs.org/download/release/v${version}/node-v${version}.tar.xz";
-      sha256 = "19az7mxcb3d1aj0f7gvhriyyghn1rwn0425924pa84d6j1mbsljv";
-    };
-
-    patches = stdenv.lib.optionals stdenv.isDarwin [ ./no-xcode-v7.patch ];
-  })
+    sha256 = "19az7mxcb3d1aj0f7gvhriyyghn1rwn0425924pa84d6j1mbsljv";
+    patches = lib.optionals stdenv.isDarwin [ ./no-xcode-v7.patch ];
+  }