Add empty node-packages.nix using build-node-package.nix from npm2nix.
buildNodePackage is a function to build npm packages. npm2nix (https://bitbucket.org/shlevy/npm2nix) can be used to generate subexpressions to go in node-packages.nix
This commit is contained in:
parent
7bfdeb102b
commit
c516517656
35
pkgs/development/web/nodejs/build-node-package.nix
Normal file
35
pkgs/development/web/nodejs/build-node-package.nix
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{ stdenv, nodejs }:
|
||||||
|
|
||||||
|
args @ { src, deps, ... }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation ({
|
||||||
|
unpackPhase = "true";
|
||||||
|
|
||||||
|
configurePhase = ''
|
||||||
|
runHook preConfigure
|
||||||
|
mkdir node_modules
|
||||||
|
${stdenv.lib.concatStrings (map (dep: ''
|
||||||
|
ln -sv ${dep}/node_modules/${(builtins.parseDrvName dep.name).name} node_modules/
|
||||||
|
'') deps)}
|
||||||
|
export HOME=$(pwd)
|
||||||
|
runHook postConfigure
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
${nodejs}/bin/npm --registry http://www.example.com install ${src}
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
mkdir $out
|
||||||
|
mv node_modules $out
|
||||||
|
if [ -d "$out/node_modules/.bin" ]; then
|
||||||
|
ln -sv node_modules/.bin $out/bin
|
||||||
|
find -L $out/node_modules/.bin/* -type f -print0 | \
|
||||||
|
xargs -0 sed --follow-symlinks -i 's@#!/usr/bin/env node@#!${nodejs}/bin/node@'
|
||||||
|
fi
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
} // args)
|
12
pkgs/top-level/node-packages.nix
Normal file
12
pkgs/top-level/node-packages.nix
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{ pkgs, stdenv, nodejs }:
|
||||||
|
|
||||||
|
let buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
|
||||||
|
inherit stdenv nodejs;
|
||||||
|
}; in
|
||||||
|
|
||||||
|
with pkgs;
|
||||||
|
|
||||||
|
let self = {
|
||||||
|
};
|
||||||
|
|
||||||
|
in self
|
Loading…
x
Reference in New Issue
Block a user