Skip to content

Commit 76782d6

Browse files
Unformat Nix files
1 parent 6220703 commit 76782d6

File tree

3 files changed

+114
-123
lines changed

3 files changed

+114
-123
lines changed

lsp/client-extension/default.nix

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
# This file has been generated by node2nix 1.11.1. Do not edit!
22

3-
{ pkgs ? import <nixpkgs> {
3+
{pkgs ? import <nixpkgs> {
44
inherit system;
5-
}
6-
, system ? builtins.currentSystem
7-
, nodejs ? pkgs."nodejs-14_x"
8-
}:
5+
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-14_x"}:
96

107
let
118
nodeEnv = import ./node-env.nix {

lsp/client-extension/node-env.nix

Lines changed: 110 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file originates from node2nix
22

3-
{ lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript }:
3+
{lib, stdenv, nodejs, python2, pkgs, libtool, runCommand, writeTextFile, writeShellScript}:
44

55
let
66
# Workaround to cope with utillinux in Nixpkgs 20.09 and util-linux in Nixpkgs master
@@ -9,7 +9,7 @@ let
99
python = if nodejs ? python then nodejs.python else python2;
1010

1111
# Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
12-
tarWrapper = runCommand "tarWrapper" { } ''
12+
tarWrapper = runCommand "tarWrapper" {} ''
1313
mkdir -p $out/bin
1414
1515
cat > $out/bin/tar <<EOF
@@ -90,36 +90,34 @@ let
9090
# Bundle the dependencies of the package
9191
#
9292
# Only include dependencies if they don't exist. They may also be bundled in the package.
93-
includeDependencies = { dependencies }:
94-
lib.optionalString (dependencies != [ ]) (
93+
includeDependencies = {dependencies}:
94+
lib.optionalString (dependencies != []) (
9595
''
9696
mkdir -p node_modules
9797
cd node_modules
9898
''
99-
+ (lib.concatMapStrings
100-
(dependency:
101-
''
102-
if [ ! -e "${dependency.packageName}" ]; then
103-
${composePackage dependency}
104-
fi
105-
''
106-
)
107-
dependencies)
99+
+ (lib.concatMapStrings (dependency:
100+
''
101+
if [ ! -e "${dependency.packageName}" ]; then
102+
${composePackage dependency}
103+
fi
104+
''
105+
) dependencies)
108106
+ ''
109107
cd ..
110108
''
111109
);
112110

113111
# Recursively composes the dependencies of a package
114-
composePackage = { name, packageName, src, dependencies ? [ ], ... }@args:
112+
composePackage = { name, packageName, src, dependencies ? [], ... }@args:
115113
builtins.addErrorContext "while evaluating node package '${packageName}'" ''
116114
installPackage "${packageName}" "${src}"
117115
${includeDependencies { inherit dependencies; }}
118116
cd ..
119117
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
120118
'';
121119

122-
pinpointDependencies = { dependencies, production }:
120+
pinpointDependencies = {dependencies, production}:
123121
let
124122
pinpointDependenciesFromPackageJSON = writeTextFile {
125123
name = "pinpointDependencies.js";
@@ -196,7 +194,7 @@ let
196194
# dependencies in the package.json file to the versions that are actually
197195
# being used.
198196

199-
pinpointDependenciesOfPackage = { packageName, dependencies ? [ ], production ? true, ... }@args:
197+
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
200198
''
201199
if [ -d "${packageName}" ]
202200
then
@@ -209,7 +207,7 @@ let
209207

210208
# Extract the Node.js source code which is used to compile packages with
211209
# native bindings
212-
nodeSources = runCommand "node-sources" { } ''
210+
nodeSources = runCommand "node-sources" {} ''
213211
tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
214212
mv node-* $out
215213
'';
@@ -416,73 +414,73 @@ let
416414
'';
417415
};
418416

419-
prepareAndInvokeNPM = { packageName, bypassCache, reconstructLock, npmFlags, production }:
417+
prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
420418
let
421419
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
422420
in
423421
''
424-
# Pinpoint the versions of all dependencies to the ones that are actually being used
425-
echo "pinpointing versions of dependencies..."
426-
source $pinpointDependenciesScriptPath
427-
428-
# Patch the shebangs of the bundled modules to prevent them from
429-
# calling executables outside the Nix store as much as possible
430-
patchShebangs .
431-
432-
# Deploy the Node.js package by running npm install. Since the
433-
# dependencies have been provided already by ourselves, it should not
434-
# attempt to install them again, which is good, because we want to make
435-
# it Nix's responsibility. If it needs to install any dependencies
436-
# anyway (e.g. because the dependency parameters are
437-
# incomplete/incorrect), it fails.
438-
#
439-
# The other responsibilities of NPM are kept -- version checks, build
440-
# steps, postprocessing etc.
441-
442-
export HOME=$TMPDIR
443-
cd "${packageName}"
444-
runHook preRebuild
445-
446-
${lib.optionalString bypassCache ''
447-
${lib.optionalString reconstructLock ''
448-
if [ -f package-lock.json ]
449-
then
450-
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
451-
echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
452-
rm package-lock.json
453-
else
454-
echo "No package-lock.json file found, reconstructing..."
455-
fi
422+
# Pinpoint the versions of all dependencies to the ones that are actually being used
423+
echo "pinpointing versions of dependencies..."
424+
source $pinpointDependenciesScriptPath
425+
426+
# Patch the shebangs of the bundled modules to prevent them from
427+
# calling executables outside the Nix store as much as possible
428+
patchShebangs .
429+
430+
# Deploy the Node.js package by running npm install. Since the
431+
# dependencies have been provided already by ourselves, it should not
432+
# attempt to install them again, which is good, because we want to make
433+
# it Nix's responsibility. If it needs to install any dependencies
434+
# anyway (e.g. because the dependency parameters are
435+
# incomplete/incorrect), it fails.
436+
#
437+
# The other responsibilities of NPM are kept -- version checks, build
438+
# steps, postprocessing etc.
456439
457-
node ${reconstructPackageLock}
458-
''}
440+
export HOME=$TMPDIR
441+
cd "${packageName}"
442+
runHook preRebuild
459443
460-
node ${addIntegrityFieldsScript}
461-
''}
444+
${lib.optionalString bypassCache ''
445+
${lib.optionalString reconstructLock ''
446+
if [ -f package-lock.json ]
447+
then
448+
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
449+
echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
450+
rm package-lock.json
451+
else
452+
echo "No package-lock.json file found, reconstructing..."
453+
fi
462454
463-
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
455+
node ${reconstructPackageLock}
456+
''}
464457
465-
runHook postRebuild
458+
node ${addIntegrityFieldsScript}
459+
''}
466460
467-
if [ "''${dontNpmInstall-}" != "1" ]
468-
then
469-
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
470-
rm -f npm-shrinkwrap.json
461+
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
471462
472-
npm ${forceOfflineFlag} --nodedir=${nodeSources} --no-bin-links --ignore-scripts ${npmFlags} ${lib.optionalString production "--production"} install
473-
fi
463+
runHook postRebuild
464+
465+
if [ "''${dontNpmInstall-}" != "1" ]
466+
then
467+
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
468+
rm -f npm-shrinkwrap.json
469+
470+
npm ${forceOfflineFlag} --nodedir=${nodeSources} --no-bin-links --ignore-scripts ${npmFlags} ${lib.optionalString production "--production"} install
471+
fi
474472
475-
# Link executables defined in package.json
476-
node ${linkBinsScript}
473+
# Link executables defined in package.json
474+
node ${linkBinsScript}
477475
'';
478476

479477
# Builds and composes an NPM package including all its dependencies
480478
buildNodePackage =
481479
{ name
482480
, packageName
483481
, version ? null
484-
, dependencies ? [ ]
485-
, buildInputs ? [ ]
482+
, dependencies ? []
483+
, buildInputs ? []
486484
, production ? true
487485
, npmFlags ? ""
488486
, dontNpmInstall ? false
@@ -492,9 +490,8 @@ let
492490
, dontStrip ? true
493491
, unpackPhase ? "true"
494492
, buildPhase ? "true"
495-
, meta ? { }
496-
, ...
497-
}@args:
493+
, meta ? {}
494+
, ... }@args:
498495

499496
let
500497
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
@@ -572,8 +569,8 @@ let
572569
, packageName
573570
, version ? null
574571
, src
575-
, dependencies ? [ ]
576-
, buildInputs ? [ ]
572+
, dependencies ? []
573+
, buildInputs ? []
577574
, production ? true
578575
, npmFlags ? ""
579576
, dontNpmInstall ? false
@@ -582,70 +579,69 @@ let
582579
, dontStrip ? true
583580
, unpackPhase ? "true"
584581
, buildPhase ? "true"
585-
, ...
586-
}@args:
582+
, ... }@args:
587583

588584
let
589585
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
590586
in
591-
stdenv.mkDerivation ({
592-
name = "node-dependencies-${name}${if version == null then "" else "-${version}"}";
587+
stdenv.mkDerivation ({
588+
name = "node-dependencies-${name}${if version == null then "" else "-${version}"}";
593589

594-
buildInputs = [ tarWrapper python nodejs ]
595-
++ lib.optional (stdenv.isLinux) utillinux
596-
++ lib.optional (stdenv.isDarwin) libtool
597-
++ buildInputs;
590+
buildInputs = [ tarWrapper python nodejs ]
591+
++ lib.optional (stdenv.isLinux) utillinux
592+
++ lib.optional (stdenv.isDarwin) libtool
593+
++ buildInputs;
598594

599-
inherit dontStrip; # Stripping may fail a build for some package deployments
600-
inherit dontNpmInstall unpackPhase buildPhase;
595+
inherit dontStrip; # Stripping may fail a build for some package deployments
596+
inherit dontNpmInstall unpackPhase buildPhase;
601597

602-
includeScript = includeDependencies { inherit dependencies; };
603-
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
598+
includeScript = includeDependencies { inherit dependencies; };
599+
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
604600

605-
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
601+
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
606602

607-
installPhase = ''
608-
source ${installPackage}
603+
installPhase = ''
604+
source ${installPackage}
609605
610-
mkdir -p $out/${packageName}
611-
cd $out/${packageName}
606+
mkdir -p $out/${packageName}
607+
cd $out/${packageName}
612608
613-
source $includeScriptPath
609+
source $includeScriptPath
614610
615-
# Create fake package.json to make the npm commands work properly
616-
cp ${src}/package.json .
617-
chmod 644 package.json
618-
${lib.optionalString bypassCache ''
619-
if [ -f ${src}/package-lock.json ]
620-
then
621-
cp ${src}/package-lock.json .
622-
chmod 644 package-lock.json
623-
fi
624-
''}
611+
# Create fake package.json to make the npm commands work properly
612+
cp ${src}/package.json .
613+
chmod 644 package.json
614+
${lib.optionalString bypassCache ''
615+
if [ -f ${src}/package-lock.json ]
616+
then
617+
cp ${src}/package-lock.json .
618+
chmod 644 package-lock.json
619+
fi
620+
''}
625621
626-
# Go to the parent folder to make sure that all packages are pinpointed
627-
cd ..
628-
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
622+
# Go to the parent folder to make sure that all packages are pinpointed
623+
cd ..
624+
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
629625
630-
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
626+
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
631627
632-
# Expose the executables that were installed
633-
cd ..
634-
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
628+
# Expose the executables that were installed
629+
cd ..
630+
${lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
635631
636-
mv ${packageName} lib
637-
ln -s $out/lib/node_modules/.bin $out/bin
638-
'';
639-
} // extraArgs);
632+
mv ${packageName} lib
633+
ln -s $out/lib/node_modules/.bin $out/bin
634+
'';
635+
} // extraArgs);
640636

641637
# Builds a development shell
642638
buildNodeShell =
643639
{ name
644640
, packageName
645641
, version ? null
646642
, src
647-
, dependencies ? [ ]
648-
, buildInputs ? [ ]
643+
, dependencies ? []
644+
, buildInputs ? []
649645
, production ? true
650646
, npmFlags ? ""
651647
, dontNpmInstall ? false
@@ -654,8 +650,7 @@ let
654650
, dontStrip ? true
655651
, unpackPhase ? "true"
656652
, buildPhase ? "true"
657-
, ...
658-
}@args:
653+
, ... }@args:
659654

660655
let
661656
nodeDependencies = buildNodeDependencies args;
@@ -677,7 +672,7 @@ let
677672

678673
# Provide the dependencies in a development shell through the NODE_PATH environment variable
679674
inherit nodeDependencies;
680-
shellHook = lib.optionalString (dependencies != [ ]) ''
675+
shellHook = lib.optionalString (dependencies != []) ''
681676
export NODE_PATH=${nodeDependencies}/lib/node_modules
682677
export PATH="${nodeDependencies}/bin:$PATH"
683678
'';

lsp/client-extension/node-packages.nix

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file has been generated by node2nix 1.11.1. Do not edit!
22

3-
{ nodeEnv, fetchurl, fetchgit, nix-gitignore, stdenv, lib, globalBuildInputs ? [ ] }:
3+
{nodeEnv, fetchurl, fetchgit, nix-gitignore, stdenv, lib, globalBuildInputs ? []}:
44

55
let
66
sources = {
@@ -3119,8 +3119,7 @@ in
31193119
"*"
31203120
"!package.json"
31213121
"!package-lock.json"
3122-
]
3123-
args.src;
3122+
] args.src;
31243123
dontBuild = true;
31253124
installPhase = "mkdir -p $out; cp -r ./* $out;";
31263125
};

0 commit comments

Comments
 (0)