From 93cdc526c3201135f46097d166563b610e1d2fad Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sat, 27 Jul 2013 13:23:35 -0400 Subject: [PATCH] buildNodePackages: Move /node_modules to /lib/node_modules to make nix profiles usable as an npm prefix Signed-off-by: Shea Levy --- .../web/nodejs/build-node-package.nix | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/development/web/nodejs/build-node-package.nix b/pkgs/development/web/nodejs/build-node-package.nix index 415f2209597c..27e114ee40bc 100644 --- a/pkgs/development/web/nodejs/build-node-package.nix +++ b/pkgs/development/web/nodejs/build-node-package.nix @@ -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 '';