about summary refs log tree commit diff
path: root/pkgs/development/web
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2013-06-05 12:25:41 -0400
committerShea Levy <shea@shealevy.com>2013-06-05 12:25:41 -0400
commit82478060903ef09afb775b6a04219739da733c03 (patch)
tree790cb14ba1491168e556fca002264a3ddfeeee99 /pkgs/development/web
parentea7f862aebe2174478c3dc048e878f554a37ba4e (diff)
downloadnixlib-82478060903ef09afb775b6a04219739da733c03.tar
nixlib-82478060903ef09afb775b6a04219739da733c03.tar.gz
nixlib-82478060903ef09afb775b6a04219739da733c03.tar.bz2
nixlib-82478060903ef09afb775b6a04219739da733c03.tar.lz
nixlib-82478060903ef09afb775b6a04219739da733c03.tar.xz
nixlib-82478060903ef09afb775b6a04219739da733c03.tar.zst
nixlib-82478060903ef09afb775b6a04219739da733c03.zip
buildNodePackage: Move dependency symlinks out of the top-level node_modules directory
Signed-off-by: Shea Levy <shea@shealevy.com>
Diffstat (limited to 'pkgs/development/web')
-rw-r--r--pkgs/development/web/nodejs/build-node-package.nix21
1 files changed, 13 insertions, 8 deletions
diff --git a/pkgs/development/web/nodejs/build-node-package.nix b/pkgs/development/web/nodejs/build-node-package.nix
index 5c75513496bd..d18a85d44ec5 100644
--- a/pkgs/development/web/nodejs/build-node-package.nix
+++ b/pkgs/development/web/nodejs/build-node-package.nix
@@ -1,15 +1,18 @@
 { stdenv, runCommand, nodejs, neededNatives}:
 
-args @ { src, deps ? [], flags ? [], ... }:
+args @ { name, src, deps ? [], flags ? [], ... }:
 
 with stdenv.lib;
 
-let npmFlags = concatStringsSep " " (map (v: "--${v}") flags);
-    sources = runCommand "node-sources" {} ''
-      tar xf ${nodejs.src}
-      mv *node* $out
-    '';
+let
+  npmFlags = concatStringsSep " " (map (v: "--${v}") flags);
 
+  sources = runCommand "node-sources" {} ''
+    tar xf ${nodejs.src}
+    mv *node* $out
+  '';
+
+  requireName = (builtins.parseDrvName name).name;
 in
 stdenv.mkDerivation ({
   unpackPhase = "true";
@@ -34,8 +37,10 @@ stdenv.mkDerivation ({
 
   installPhase = ''
     runHook preInstall
-    mkdir $out
-    mv node_modules $out
+    mkdir -p $out/node_modules
+    mv node_modules/${requireName} $out/node_modules
+    mv node_modules/.bin $out/node_modules 2>/dev/null || true
+    mv node_modules $out/node_modules/${requireName}
     if [ -d "$out/node_modules/.bin" ]; then
       ln -sv node_modules/.bin $out/bin
       find -L $out/node_modules/.bin/* -type f -print0 | \