Add karma nodePackage
Required updating to npm2nix 5.1.0 for peerDependency cycle management Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
9c9b7a427b
commit
7188cc39fa
@ -1,6 +1,6 @@
|
|||||||
{ stdenv, runCommand, nodejs, neededNatives}:
|
{ stdenv, runCommand, nodejs, neededNatives}:
|
||||||
|
|
||||||
args @ { name, src, deps ? [], peerDeps ? [], flags ? [], ... }:
|
args @ { name, src, deps ? [], peerDependencies ? [], flags ? [], ... }:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
@ -11,8 +11,6 @@ let
|
|||||||
tar xf ${nodejs.src}
|
tar xf ${nodejs.src}
|
||||||
mv *node* $out
|
mv *node* $out
|
||||||
'';
|
'';
|
||||||
|
|
||||||
requireName = name: (builtins.parseDrvName name).name;
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
unpackPhase = "true";
|
unpackPhase = "true";
|
||||||
@ -20,32 +18,44 @@ stdenv.mkDerivation ({
|
|||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
runHook preConfigure
|
runHook preConfigure
|
||||||
mkdir node_modules
|
mkdir node_modules
|
||||||
${stdenv.lib.concatStrings (map (dep: ''
|
${concatStrings (concatMap (dep: map (name: ''
|
||||||
ln -sv ${dep}/lib/node_modules/${requireName dep.name} node_modules/
|
ln -sv ${dep}/lib/node_modules/${name} node_modules/
|
||||||
'') deps)}
|
'') dep.names) deps)}
|
||||||
${stdenv.lib.concatStrings (map (dep: ''
|
${concatStrings (concatMap (dep: map (name: ''
|
||||||
ln -sv ${dep}/lib/node_modules/${requireName dep.name} node_modules/
|
ln -sv ${dep}/lib/node_modules/${name} node_modules/
|
||||||
'') peerDeps)}
|
'') dep.names) peerDependencies)}
|
||||||
export HOME=$(pwd)
|
export HOME=$(pwd)
|
||||||
runHook postConfigure
|
runHook postConfigure
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
npm --registry http://www.example.com --nodedir=${sources} install ${src} ${npmFlags}
|
npm --registry http://www.example.com --nodedir=${sources} install ${concatStringsSep " " src} ${npmFlags}
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir -p $out/lib/node_modules
|
mkdir -p $out/lib/node_modules
|
||||||
mv node_modules/${requireName name} $out/lib/node_modules
|
${concatStrings (map (name: ''
|
||||||
${stdenv.lib.concatStrings (map (dep: ''
|
mv node_modules/${name} $out/lib/node_modules
|
||||||
mv node_modules/${requireName dep.name} $out/lib/node_modules
|
rm -fR $out/lib/node_modules/${name}/node_modules
|
||||||
'') peerDeps)}
|
ln -sv $out/.dependent-node-modules $out/lib/node_modules/${name}/node_modules
|
||||||
|
if [ -e "$out/lib/node_modules/${name}/man" ]; then
|
||||||
|
mkdir -p $out/share
|
||||||
|
for dir in "$out/lib/node_modules/${name}/man/"*; do
|
||||||
|
mkdir -p $out/share/man/$(basename "$dir")
|
||||||
|
for page in "$dir"/*; do
|
||||||
|
ln -sv $page $out/share/man/$(basename "$dir")
|
||||||
|
done
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
'') args.passthru.names)}
|
||||||
|
${concatStrings (concatMap (dep: map (name: ''
|
||||||
|
mv node_modules/${dep.name} $out/lib/node_modules
|
||||||
|
'') dep.names) peerDependencies)}
|
||||||
mv node_modules/.bin $out/lib/node_modules 2>/dev/null || true
|
mv node_modules/.bin $out/lib/node_modules 2>/dev/null || true
|
||||||
rm -fR $out/lib/node_modules/${requireName name}/node_modules
|
mv node_modules $out/.dependent-node-modules
|
||||||
mv node_modules $out/lib/node_modules/${requireName name}
|
|
||||||
if [ -d "$out/lib/node_modules/.bin" ]; then
|
if [ -d "$out/lib/node_modules/.bin" ]; then
|
||||||
ln -sv $out/lib/node_modules/.bin $out/bin
|
ln -sv $out/lib/node_modules/.bin $out/bin
|
||||||
node=`type -p node`
|
node=`type -p node`
|
||||||
@ -57,20 +67,16 @@ stdenv.mkDerivation ({
|
|||||||
-e 's@#!/.*/node@#!'"$node"'@' \
|
-e 's@#!/.*/node@#!'"$node"'@' \
|
||||||
-e 's@#!/.*/coffee@#!'"$coffee"'@'
|
-e 's@#!/.*/coffee@#!'"$coffee"'@'
|
||||||
fi
|
fi
|
||||||
if [ -e "$out/lib/node_modules/${requireName name}/man" ]; then
|
|
||||||
mkdir $out/share
|
|
||||||
ln -sv $out/lib/node_modules/${requireName name}/man $out/share/man
|
|
||||||
fi
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preFixup = ''
|
preFixup = concatStringsSep "\n" (map (src: ''
|
||||||
find $out -type f -print0 | xargs -0 sed -i 's|${src}|${src.name}|g'
|
find $out -type f -print0 | xargs -0 sed -i 's|${src}|${src.name}|g'
|
||||||
'';
|
'') src);
|
||||||
} // args // {
|
} // args // {
|
||||||
# Run the node setup hook when this package is a build input
|
# Run the node setup hook when this package is a build input
|
||||||
propagatedNativeBuildInputs = (args.propagatedNativeBuildInputs or []) ++ [ nodejs ];
|
propagatedNativeBuildInputs = (args.propagatedNativeBuildInputs or []) ++ [ nodejs ];
|
||||||
|
|
||||||
# Make buildNodePackage useful with --run-env
|
# Make buildNodePackage useful with --run-env
|
||||||
nativeBuildInputs = (args.nativeBuildInputs or []) ++ deps ++ peerDeps ++ neededNatives;
|
nativeBuildInputs = (args.nativeBuildInputs or []) ++ deps ++ peerDependencies ++ neededNatives;
|
||||||
} )
|
} )
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -73,6 +73,7 @@
|
|||||||
, "generator-webapp"
|
, "generator-webapp"
|
||||||
, "generator-angular"
|
, "generator-angular"
|
||||||
, "statsd"
|
, "statsd"
|
||||||
|
, "karma"
|
||||||
, { "node-uptime": "https://github.com/fzaninotto/uptime/tarball/1c65756575f90f563a752e2a22892ba2981c79b7" }
|
, { "node-uptime": "https://github.com/fzaninotto/uptime/tarball/1c65756575f90f563a752e2a22892ba2981c79b7" }
|
||||||
, { "guifi-earth": "https://github.com/jmendeth/guifi-earth/tarball/f3ee96835fd4fb0e3e12fadbd2cb782770d64854 " }
|
, { "guifi-earth": "https://github.com/jmendeth/guifi-earth/tarball/f3ee96835fd4fb0e3e12fadbd2cb782770d64854 " }
|
||||||
]
|
]
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
nativeDeps = {
|
nativeDeps = {
|
||||||
"node-expat"."*" = [ pkgs.expat ];
|
"node-expat"."*" = [ pkgs.expat ];
|
||||||
"rbytes"."0.0.2" = [ pkgs.openssl ];
|
"rbytes"."0.0.2" = [ pkgs.openssl ];
|
||||||
|
"phantomjs"."~1.9" = [ pkgs.phantomjs ];
|
||||||
};
|
};
|
||||||
|
|
||||||
buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
|
buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
|
||||||
|
Loading…
Reference in New Issue
Block a user