buildNodePackages: Move /node_modules to /lib/node_modules to make nix profiles usable as an npm prefix
Signed-off-by: Shea Levy <shea@shealevy.com>
This commit is contained in:
parent
595937318f
commit
93cdc526c3
@ -21,7 +21,7 @@ stdenv.mkDerivation ({
|
||||
runHook preConfigure
|
||||
mkdir node_modules
|
||||
${stdenv.lib.concatStrings (map (dep: ''
|
||||
ln -sv ${dep}/node_modules/${(builtins.parseDrvName dep.name).name} node_modules/
|
||||
ln -sv ${dep}/lib/node_modules/${(builtins.parseDrvName dep.name).name} node_modules/
|
||||
'') deps)}
|
||||
export HOME=$(pwd)
|
||||
runHook postConfigure
|
||||
@ -35,25 +35,25 @@ stdenv.mkDerivation ({
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
mkdir -p $out/node_modules
|
||||
mv node_modules/${requireName} $out/node_modules
|
||||
mv node_modules/.bin $out/node_modules 2>/dev/null || true
|
||||
rm -fR $out/node_modules/${requireName}/node_modules
|
||||
mv node_modules $out/node_modules/${requireName}
|
||||
if [ -d "$out/node_modules/.bin" ]; then
|
||||
mkdir -p $out/lib/node_modules
|
||||
mv node_modules/${requireName} $out/lib/node_modules
|
||||
mv node_modules/.bin $out/lib/node_modules 2>/dev/null || true
|
||||
rm -fR $out/lib/node_modules/${requireName}/node_modules
|
||||
mv node_modules $out/lib/node_modules/${requireName}
|
||||
if [ -d "$out/lib/node_modules/.bin" ]; then
|
||||
ln -sv node_modules/.bin $out/bin
|
||||
node=`type -p node`
|
||||
coffee=`type -p coffee || true`
|
||||
find -L $out/node_modules/.bin/* -type f -print0 | \
|
||||
find -L $out/lib/node_modules/.bin/* -type f -print0 | \
|
||||
xargs -0 sed --follow-symlinks -i \
|
||||
-e 's@#!/usr/bin/env node@#!'"$node"'@' \
|
||||
-e 's@#!/usr/bin/env coffee@#!'"$coffee"'@' \
|
||||
-e 's@#!/.*/node@#!'"$node"'@' \
|
||||
-e 's@#!/.*/coffee@#!'"$coffee"'@'
|
||||
fi
|
||||
if [ -e "$out/node_modules/${requireName}/man" ]; then
|
||||
if [ -e "$out/lib/node_modules/${requireName}/man" ]; then
|
||||
mkdir $out/share
|
||||
ln -sv node_modules/${requireName}/man $out/share/man
|
||||
ln -sv $out/lib/node_modules/${requireName}/man $out/share/man
|
||||
fi
|
||||
runHook postInstall
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user