Skip to content

Commit 5e563ae

Browse files
committedNov 3, 2017
node2nix: 1.3.0 -> 1.4.0 + regenerate packages
1 parent 94043f5 commit 5e563ae

File tree

5 files changed

+3997
-12203
lines changed

5 files changed

+3997
-12203
lines changed
 

‎pkgs/development/node-packages/composition-v4.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file has been generated by node2nix 1.3.0. Do not edit!
1+
# This file has been generated by node2nix 1.4.0. Do not edit!
22

33
{pkgs ? import <nixpkgs> {
44
inherit system;

‎pkgs/development/node-packages/composition-v6.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file has been generated by node2nix 1.3.0. Do not edit!
1+
# This file has been generated by node2nix 1.4.0. Do not edit!
22

33
{pkgs ? import <nixpkgs> {
44
inherit system;

‎pkgs/development/node-packages/node-env.nix

+27-25
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,16 @@ let
110110
text = ''
111111
var fs = require('fs');
112112
var path = require('path');
113-
113+
114114
function resolveDependencyVersion(location, name) {
115115
if(location == process.env['NIX_STORE']) {
116116
return null;
117117
} else {
118118
var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
119-
119+
120120
if(fs.existsSync(dependencyPackageJSON)) {
121121
var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
122-
122+
123123
if(dependencyPackageObj.name == name) {
124124
return dependencyPackageObj.version;
125125
}
@@ -128,12 +128,12 @@ let
128128
}
129129
}
130130
}
131-
131+
132132
function replaceDependencies(dependencies) {
133133
if(typeof dependencies == "object" && dependencies !== null) {
134134
for(var dependency in dependencies) {
135135
var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
136-
136+
137137
if(resolvedVersion === null) {
138138
process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
139139
} else {
@@ -142,25 +142,25 @@ let
142142
}
143143
}
144144
}
145-
145+
146146
/* Read the package.json configuration */
147147
var packageObj = JSON.parse(fs.readFileSync('./package.json'));
148-
148+
149149
/* Pinpoint all dependencies */
150150
replaceDependencies(packageObj.dependencies);
151151
if(process.argv[2] == "development") {
152152
replaceDependencies(packageObj.devDependencies);
153153
}
154154
replaceDependencies(packageObj.optionalDependencies);
155-
155+
156156
/* Write the fixed package.json file */
157157
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
158158
'';
159159
};
160160
in
161161
''
162162
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
163-
163+
164164
${stdenv.lib.optionalString (dependencies != [])
165165
''
166166
if [ -d node_modules ]
@@ -171,11 +171,11 @@ let
171171
fi
172172
''}
173173
'';
174-
174+
175175
# Recursively traverses all dependencies of a package and pinpoints all
176176
# dependencies in the package.json file to the versions that are actually
177177
# being used.
178-
178+
179179
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
180180
''
181181
if [ -d "${packageName}" ]
@@ -210,7 +210,7 @@ let
210210

211211
compositionScript = composePackage args;
212212
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
213-
213+
214214
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
215215

216216
installPhase = args.installPhase or ''
@@ -220,7 +220,7 @@ let
220220
221221
# Compose the package and all its dependencies
222222
source $compositionScriptPath
223-
223+
224224
# Pinpoint the versions of all dependencies to the ones that are actually being used
225225
echo "pinpointing versions of dependencies..."
226226
source $pinpointDependenciesScriptPath
@@ -287,31 +287,31 @@ let
287287

288288
includeScript = includeDependencies { inherit dependencies; };
289289
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
290-
290+
291291
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
292292

293293
buildCommand = ''
294-
mkdir -p $out/lib
295-
cd $out/lib
294+
mkdir -p $out/${packageName}
295+
cd $out/${packageName}
296+
296297
source $includeScriptPath
297-
298+
299+
# Create fake package.json to make the npm commands work properly
300+
cp ${src}/package.json .
301+
chmod 644 package.json
302+
298303
# Pinpoint the versions of all dependencies to the ones that are actually being used
299304
echo "pinpointing versions of dependencies..."
305+
cd ..
300306
source $pinpointDependenciesScriptPath
301-
302-
# Create fake package.json to make the npm commands work properly
303-
cat > package.json <<EOF
304-
{
305-
"name": "${packageName}",
306-
"version": "${version}"
307-
}
308-
EOF
307+
cd ${packageName}
309308
310309
# Patch the shebangs of the bundled modules to prevent them from
311310
# calling executables outside the Nix store as much as possible
312311
patchShebangs .
313312
314313
export HOME=$PWD
314+
315315
npm --registry http://www.example.com --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
316316
317317
${stdenv.lib.optionalString (!dontNpmInstall) ''
@@ -321,6 +321,8 @@ let
321321
npm --registry http://www.example.com --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
322322
''}
323323
324+
cd ..
325+
mv ${packageName} lib
324326
ln -s $out/lib/node_modules/.bin $out/bin
325327
'';
326328
};

0 commit comments

Comments
 (0)
Please sign in to comment.