about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorJaka Hudoklin <jakahudoklin@gmail.com>2014-06-18 13:13:33 +0200
committerJaka Hudoklin <jakahudoklin@gmail.com>2014-06-18 13:14:15 +0200
commit05ce47f8ec57f5a186a9cc450e136831552fbb9c (patch)
tree2b6d65e1dd8633519a99b0b47f73a09f4a3d6387 /pkgs
parent36e6eda5fc21e655b172a3c8a445930bafb64e73 (diff)
downloadnixlib-05ce47f8ec57f5a186a9cc450e136831552fbb9c.tar
nixlib-05ce47f8ec57f5a186a9cc450e136831552fbb9c.tar.gz
nixlib-05ce47f8ec57f5a186a9cc450e136831552fbb9c.tar.bz2
nixlib-05ce47f8ec57f5a186a9cc450e136831552fbb9c.tar.lz
nixlib-05ce47f8ec57f5a186a9cc450e136831552fbb9c.tar.xz
nixlib-05ce47f8ec57f5a186a9cc450e136831552fbb9c.tar.zst
nixlib-05ce47f8ec57f5a186a9cc450e136831552fbb9c.zip
buildNodePackage: add shell hook for development
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/web/nodejs/build-node-package.nix12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkgs/development/web/nodejs/build-node-package.nix b/pkgs/development/web/nodejs/build-node-package.nix
index 544634626b03..84b0da1674c4 100644
--- a/pkgs/development/web/nodejs/build-node-package.nix
+++ b/pkgs/development/web/nodejs/build-node-package.nix
@@ -1,6 +1,6 @@
 { stdenv, runCommand, nodejs, neededNatives}:
 
-args @ { name, src, deps ? [], peerDependencies ? [], flags ? [], ... }:
+args @ { name, src, deps ? [], peerDependencies ? [], flags ? [], preShellHook ? "",  postShellHook ? "", ... }:
 
 with stdenv.lib;
 
@@ -80,6 +80,16 @@ stdenv.mkDerivation ({
   preFixup = concatStringsSep "\n" (map (src: ''
     find $out -type f -print0 | xargs -0 sed -i 's|${src}|${src.name}|g'
   '') src);
+
+  shellHook = ''
+    ${preShellHook}
+    export PATH=${nodejs}/bin:$(pwd)/node_modules/.bin:$PATH
+    mkdir -p node_modules
+    ${concatStrings (concatMap (dep: map (name: ''
+      ln -sfv ${dep}/lib/node_modules/${name} node_modules/
+    '') dep.names) deps)}
+    ${postShellHook}
+  '';
 } // args // {
   # Run the node setup hook when this package is a build input
   propagatedNativeBuildInputs = (args.propagatedNativeBuildInputs or []) ++ [ nodejs ];