node-packages: ability to build npms that have native extensions

This commit is contained in:
Mathijs Kwik 2012-09-13 14:35:35 +02:00
parent 9a65507b0f
commit baa6223904
3 changed files with 19 additions and 5 deletions

View File

@ -1,7 +1,16 @@
{ stdenv, nodejs }:
{ stdenv, runCommand, nodejs, neededNatives}:
args @ { src, deps, ... }:
args @ { src, deps ? [], nativeDeps ? [], flags ? [], ... }:
with stdenv.lib;
let npmFlags = concatStringsSep " " (map (v: "--${v}") flags);
sources = runCommand "node-sources" {} ''
tar xf ${nodejs.src}
mv node-v${nodejs.version} $out
'';
in
stdenv.mkDerivation ({
unpackPhase = "true";
@ -17,10 +26,13 @@ stdenv.mkDerivation ({
buildPhase = ''
runHook preBuild
${nodejs}/bin/npm --registry http://www.example.com install ${src}
${nodejs}/bin/npm --registry http://www.example.com --nodedir=${sources} install ${src} ${npmFlags}
runHook postBuild
'';
buildNativeInputs = neededNatives;
buildInputs = nativeDeps;
installPhase = ''
runHook preInstall
mkdir $out

View File

@ -990,6 +990,7 @@ let
nodePackages = recurseIntoAttrs (import ./node-packages.nix {
inherit pkgs stdenv nodejs fetchurl;
neededNatives = [python] ++ lib.optional (lib.elem system lib.platforms.linux) utillinux;
});
ldns = callPackage ../development/libraries/ldns { };

View File

@ -1,8 +1,9 @@
{ pkgs, stdenv, nodejs, fetchurl }:
{ pkgs, stdenv, nodejs, fetchurl, neededNatives }:
let self = {
buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
inherit stdenv nodejs;
inherit stdenv nodejs neededNatives;
inherit (pkgs) runCommand;
};
patchLatest = srcAttrs: