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