anchor.diff:      });
   
     # Builds a development shell
  -  buildNodeShell = { name, version, src, dependencies ? [], ... }@args:
  +  buildNodeShell = { name, version, src, dependencies ? [], production ? true, npmFlags ? "", ... }@args:
       let
         nodeDependencies = stdenv.mkDerivation {
           name = "node-dependencies-${name}-${version}";
  +        
  +        buildInputs = [ python nodejs ] ++ stdenv.lib.optional (stdenv.isLinux) utillinux ++ args.buildInputs or [];
  +        
  +        includeScript = includeDependencies { inherit dependencies; };
  +        passAsFile = [ "includeScript" ];
  +        
           buildCommand = ''
             mkdir -p $out/lib
             cd $out/lib
  -          ${includeDependencies { inherit dependencies; }}
  +          source $includeScriptPath
  +          
  +          # Create fake package.json to make the npm commands work properly
  +          cat > package.json <<EOF
  +          {
  +              "name": "${name}",
  +              "version": "${version}"
  +          }
  +          EOF
  +          
  +          npm --registry http://www.example.com --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
  +          npm --registry http://www.example.com --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
           '';
         };
       in
       stdenv.mkDerivation {
         name = "node-shell-${name}-${version}";
  -    
  +      
  +      buildInputs = [ python nodejs ] ++ stdenv.lib.optional (stdenv.isLinux) utillinux ++ args.buildInputs or [];
         buildCommand = "true";
         
         # Provide the dependencies in a development shell through the NODE_PATH environment variable
  
positive.code:         # The other responsibilities of NPM are kept -- version checks, build
          # steps, postprocessing etc.
          
          cd ${name}
          export HOME=$TMPDIR
          npm --registry http://www.example.com --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
          
          # Create symlink to the deployed executable folder, if applicable
  
negative.code:       
        buildPhase = args.buildPhase or "true";
        
        compositionScript = composePackage args;
        passAsFile = [ "compositionScript" ];
        
        installPhase = args.installPhase or ''
          # Create and enter a root node_modules/ folder
          mkdir -p $out/lib/node_modules
          cd $out/lib/node_modules
            
          # Compose the package and all its dependencies
          source $compositionScriptPath
          
          # Patch the shebangs of the bundled modules to prevent them from
          # calling executables outside the Nix store as much as possible
  