buildNodePackage: add shell hook for development
This commit is contained in:
parent
36e6eda5fc
commit
05ce47f8ec
|
@ -1,6 +1,6 @@
|
||||||
{ stdenv, runCommand, nodejs, neededNatives}:
|
{ stdenv, runCommand, nodejs, neededNatives}:
|
||||||
|
|
||||||
args @ { name, src, deps ? [], peerDependencies ? [], flags ? [], ... }:
|
args @ { name, src, deps ? [], peerDependencies ? [], flags ? [], preShellHook ? "", postShellHook ? "", ... }:
|
||||||
|
|
||||||
with stdenv.lib;
|
with stdenv.lib;
|
||||||
|
|
||||||
|
@ -80,6 +80,16 @@ stdenv.mkDerivation ({
|
||||||
preFixup = concatStringsSep "\n" (map (src: ''
|
preFixup = concatStringsSep "\n" (map (src: ''
|
||||||
find $out -type f -print0 | xargs -0 sed -i 's|${src}|${src.name}|g'
|
find $out -type f -print0 | xargs -0 sed -i 's|${src}|${src.name}|g'
|
||||||
'') src);
|
'') 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 // {
|
} // args // {
|
||||||
# Run the node setup hook when this package is a build input
|
# Run the node setup hook when this package is a build input
|
||||||
propagatedNativeBuildInputs = (args.propagatedNativeBuildInputs or []) ++ [ nodejs ];
|
propagatedNativeBuildInputs = (args.propagatedNativeBuildInputs or []) ++ [ nodejs ];
|
||||||
|
|
Loading…
Reference in New Issue