Skip to content

Commit

Permalink
buildNodePackage: add shell hook for development
Browse files Browse the repository at this point in the history
  • Loading branch information
offlinehacker committed Jun 18, 2014
1 parent 36e6eda commit 05ce47f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkgs/development/web/nodejs/build-node-package.nix
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 ];
Expand Down

0 comments on commit 05ce47f

Please sign in to comment.