1
1
# This file originates from node2nix
2
2
3
- { stdenv , nodejs , python2 , utillinux , libtool , runCommand , writeTextFile } :
3
+ { stdenv , lib , nodejs , python3 , utillinux , libtool , runCommand , writeTextFile } :
4
4
5
5
let
6
- python = if nodejs ? python then nodejs . python else python2 ;
6
+ python = if nodejs ? python then nodejs . python else python3 ;
7
7
8
8
# Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
9
9
tarWrapper = runCommand "tarWrapper" { } ''
38
38
} ;
39
39
40
40
includeDependencies = { dependencies } :
41
- stdenv . lib . optionalString ( dependencies != [ ] )
42
- ( stdenv . lib . concatMapStrings ( dependency :
41
+ lib . optionalString ( dependencies != [ ] )
42
+ ( lib . concatMapStrings ( dependency :
43
43
''
44
44
# Bundle the dependencies of the package
45
45
mkdir -p node_modules
100
100
cd "$DIR/${ packageName } "
101
101
${ includeDependencies { inherit dependencies ; } }
102
102
cd ..
103
- ${ stdenv . lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
103
+ ${ lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
104
104
'' ;
105
105
106
106
pinpointDependencies = { dependencies , production } :
@@ -161,12 +161,12 @@ let
161
161
''
162
162
node ${ pinpointDependenciesFromPackageJSON } ${ if production then "production" else "development" }
163
163
164
- ${ stdenv . lib . optionalString ( dependencies != [ ] )
164
+ ${ lib . optionalString ( dependencies != [ ] )
165
165
''
166
166
if [ -d node_modules ]
167
167
then
168
168
cd node_modules
169
- ${ stdenv . lib . concatMapStrings ( dependency : pinpointDependenciesOfPackage dependency ) dependencies }
169
+ ${ lib . concatMapStrings ( dependency : pinpointDependenciesOfPackage dependency ) dependencies }
170
170
cd ..
171
171
fi
172
172
'' }
183
183
cd "${ packageName } "
184
184
${ pinpointDependencies { inherit dependencies production ; } }
185
185
cd ..
186
- ${ stdenv . lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
186
+ ${ lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
187
187
fi
188
188
'' ;
189
189
344
344
cd "${ packageName } "
345
345
runHook preRebuild
346
346
347
- ${ stdenv . lib . optionalString bypassCache ''
348
- ${ stdenv . lib . optionalString reconstructLock ''
347
+ ${ lib . optionalString bypassCache ''
348
+ ${ lib . optionalString reconstructLock ''
349
349
if [ -f package-lock.json ]
350
350
then
351
351
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
@@ -361,14 +361,14 @@ let
361
361
node ${ addIntegrityFieldsScript }
362
362
'' }
363
363
364
- npm ${ forceOfflineFlag } --nodedir=${ nodeSources } ${ npmFlags } ${ stdenv . lib . optionalString production "--production" } rebuild
364
+ npm ${ forceOfflineFlag } --nodedir=${ nodeSources } ${ npmFlags } ${ lib . optionalString production "--production" } rebuild
365
365
366
366
if [ "'' ${dontNpmInstall-}" != "1" ]
367
367
then
368
368
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
369
369
rm -f npm-shrinkwrap.json
370
370
371
- npm ${ forceOfflineFlag } --nodedir=${ nodeSources } ${ npmFlags } ${ stdenv . lib . optionalString production "--production" } install
371
+ npm ${ forceOfflineFlag } --nodedir=${ nodeSources } ${ npmFlags } ${ lib . optionalString production "--production" } install
372
372
fi
373
373
'' ;
374
374
396
396
stdenv . mkDerivation ( {
397
397
name = "node_${ name } -${ version } " ;
398
398
buildInputs = [ tarWrapper python nodejs ]
399
- ++ stdenv . lib . optional ( stdenv . isLinux ) utillinux
400
- ++ stdenv . lib . optional ( stdenv . isDarwin ) libtool
399
+ ++ lib . optional ( stdenv . isLinux ) utillinux
400
+ ++ lib . optional ( stdenv . isDarwin ) libtool
401
401
++ buildInputs ;
402
402
403
403
inherit nodejs ;
470
470
name = "node-dependencies-${ name } -${ version } " ;
471
471
472
472
buildInputs = [ tarWrapper python nodejs ]
473
- ++ stdenv . lib . optional ( stdenv . isLinux ) utillinux
474
- ++ stdenv . lib . optional ( stdenv . isDarwin ) libtool
473
+ ++ lib . optional ( stdenv . isLinux ) utillinux
474
+ ++ lib . optional ( stdenv . isDarwin ) libtool
475
475
++ buildInputs ;
476
476
477
477
inherit dontStrip ; # Stripping may fail a build for some package deployments
491
491
# Create fake package.json to make the npm commands work properly
492
492
cp ${ src } /package.json .
493
493
chmod 644 package.json
494
- ${ stdenv . lib . optionalString bypassCache ''
494
+ ${ lib . optionalString bypassCache ''
495
495
if [ -f ${ src } /package-lock.json ]
496
496
then
497
497
cp ${ src } /package-lock.json .
@@ -500,13 +500,13 @@ let
500
500
501
501
# Go to the parent folder to make sure that all packages are pinpointed
502
502
cd ..
503
- ${ stdenv . lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
503
+ ${ lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
504
504
505
505
${ prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production ; } }
506
506
507
507
# Expose the executables that were installed
508
508
cd ..
509
- ${ stdenv . lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
509
+ ${ lib . optionalString ( builtins . substring 0 1 packageName == "@" ) "cd .." }
510
510
511
511
mv ${ packageName } lib
512
512
ln -s $out/lib/node_modules/.bin $out/bin
516
516
stdenv . mkDerivation {
517
517
name = "node-shell-${ name } -${ version } " ;
518
518
519
- buildInputs = [ python nodejs ] ++ stdenv . lib . optional ( stdenv . isLinux ) utillinux ++ buildInputs ;
519
+ buildInputs = [ python nodejs ] ++ lib . optional ( stdenv . isLinux ) utillinux ++ buildInputs ;
520
520
buildCommand = ''
521
521
mkdir -p $out/bin
522
522
cat > $out/bin/shell <<EOF
@@ -529,14 +529,14 @@ let
529
529
530
530
# Provide the dependencies in a development shell through the NODE_PATH environment variable
531
531
inherit nodeDependencies ;
532
- shellHook = stdenv . lib . optionalString ( dependencies != [ ] ) ''
532
+ shellHook = lib . optionalString ( dependencies != [ ] ) ''
533
533
export NODE_PATH=${ nodeDependencies } /lib/node_modules
534
534
export PATH="${ nodeDependencies } /bin:$PATH"
535
535
'' ;
536
536
} ;
537
537
in
538
538
{
539
- buildNodeSourceDist = stdenv . lib . makeOverridable buildNodeSourceDist ;
540
- buildNodePackage = stdenv . lib . makeOverridable buildNodePackage ;
541
- buildNodeShell = stdenv . lib . makeOverridable buildNodeShell ;
539
+ buildNodeSourceDist = lib . makeOverridable buildNodeSourceDist ;
540
+ buildNodePackage = lib . makeOverridable buildNodePackage ;
541
+ buildNodeShell = lib . makeOverridable buildNodeShell ;
542
542
}
0 commit comments