mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 17:33:09 +00:00
node2nix: 1.3.0 -> 1.4.0 + regenerate packages
This commit is contained in:
parent
94043f511a
commit
5e563ae749
@ -1,4 +1,4 @@
|
|||||||
# This file has been generated by node2nix 1.3.0. Do not edit!
|
# This file has been generated by node2nix 1.4.0. Do not edit!
|
||||||
|
|
||||||
{pkgs ? import <nixpkgs> {
|
{pkgs ? import <nixpkgs> {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# This file has been generated by node2nix 1.3.0. Do not edit!
|
# This file has been generated by node2nix 1.4.0. Do not edit!
|
||||||
|
|
||||||
{pkgs ? import <nixpkgs> {
|
{pkgs ? import <nixpkgs> {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
@ -110,16 +110,16 @@ let
|
|||||||
text = ''
|
text = ''
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
function resolveDependencyVersion(location, name) {
|
function resolveDependencyVersion(location, name) {
|
||||||
if(location == process.env['NIX_STORE']) {
|
if(location == process.env['NIX_STORE']) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
|
var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
|
||||||
|
|
||||||
if(fs.existsSync(dependencyPackageJSON)) {
|
if(fs.existsSync(dependencyPackageJSON)) {
|
||||||
var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
|
var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
|
||||||
|
|
||||||
if(dependencyPackageObj.name == name) {
|
if(dependencyPackageObj.name == name) {
|
||||||
return dependencyPackageObj.version;
|
return dependencyPackageObj.version;
|
||||||
}
|
}
|
||||||
@ -128,12 +128,12 @@ let
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceDependencies(dependencies) {
|
function replaceDependencies(dependencies) {
|
||||||
if(typeof dependencies == "object" && dependencies !== null) {
|
if(typeof dependencies == "object" && dependencies !== null) {
|
||||||
for(var dependency in dependencies) {
|
for(var dependency in dependencies) {
|
||||||
var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
|
var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
|
||||||
|
|
||||||
if(resolvedVersion === null) {
|
if(resolvedVersion === null) {
|
||||||
process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
|
process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
|
||||||
} else {
|
} else {
|
||||||
@ -142,17 +142,17 @@ let
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the package.json configuration */
|
/* Read the package.json configuration */
|
||||||
var packageObj = JSON.parse(fs.readFileSync('./package.json'));
|
var packageObj = JSON.parse(fs.readFileSync('./package.json'));
|
||||||
|
|
||||||
/* Pinpoint all dependencies */
|
/* Pinpoint all dependencies */
|
||||||
replaceDependencies(packageObj.dependencies);
|
replaceDependencies(packageObj.dependencies);
|
||||||
if(process.argv[2] == "development") {
|
if(process.argv[2] == "development") {
|
||||||
replaceDependencies(packageObj.devDependencies);
|
replaceDependencies(packageObj.devDependencies);
|
||||||
}
|
}
|
||||||
replaceDependencies(packageObj.optionalDependencies);
|
replaceDependencies(packageObj.optionalDependencies);
|
||||||
|
|
||||||
/* Write the fixed package.json file */
|
/* Write the fixed package.json file */
|
||||||
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
|
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
|
||||||
'';
|
'';
|
||||||
@ -160,7 +160,7 @@ let
|
|||||||
in
|
in
|
||||||
''
|
''
|
||||||
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
|
node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
|
||||||
|
|
||||||
${stdenv.lib.optionalString (dependencies != [])
|
${stdenv.lib.optionalString (dependencies != [])
|
||||||
''
|
''
|
||||||
if [ -d node_modules ]
|
if [ -d node_modules ]
|
||||||
@ -171,11 +171,11 @@ let
|
|||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Recursively traverses all dependencies of a package and pinpoints all
|
# Recursively traverses all dependencies of a package and pinpoints all
|
||||||
# dependencies in the package.json file to the versions that are actually
|
# dependencies in the package.json file to the versions that are actually
|
||||||
# being used.
|
# being used.
|
||||||
|
|
||||||
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
|
pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
|
||||||
''
|
''
|
||||||
if [ -d "${packageName}" ]
|
if [ -d "${packageName}" ]
|
||||||
@ -210,7 +210,7 @@ let
|
|||||||
|
|
||||||
compositionScript = composePackage args;
|
compositionScript = composePackage args;
|
||||||
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
||||||
|
|
||||||
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
||||||
|
|
||||||
installPhase = args.installPhase or ''
|
installPhase = args.installPhase or ''
|
||||||
@ -220,7 +220,7 @@ let
|
|||||||
|
|
||||||
# Compose the package and all its dependencies
|
# Compose the package and all its dependencies
|
||||||
source $compositionScriptPath
|
source $compositionScriptPath
|
||||||
|
|
||||||
# Pinpoint the versions of all dependencies to the ones that are actually being used
|
# Pinpoint the versions of all dependencies to the ones that are actually being used
|
||||||
echo "pinpointing versions of dependencies..."
|
echo "pinpointing versions of dependencies..."
|
||||||
source $pinpointDependenciesScriptPath
|
source $pinpointDependenciesScriptPath
|
||||||
@ -287,31 +287,31 @@ let
|
|||||||
|
|
||||||
includeScript = includeDependencies { inherit dependencies; };
|
includeScript = includeDependencies { inherit dependencies; };
|
||||||
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
||||||
|
|
||||||
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
|
passAsFile = [ "includeScript" "pinpointDependenciesScript" ];
|
||||||
|
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
mkdir -p $out/lib
|
mkdir -p $out/${packageName}
|
||||||
cd $out/lib
|
cd $out/${packageName}
|
||||||
|
|
||||||
source $includeScriptPath
|
source $includeScriptPath
|
||||||
|
|
||||||
# Pinpoint the versions of all dependencies to the ones that are actually being used
|
|
||||||
echo "pinpointing versions of dependencies..."
|
|
||||||
source $pinpointDependenciesScriptPath
|
|
||||||
|
|
||||||
# Create fake package.json to make the npm commands work properly
|
# Create fake package.json to make the npm commands work properly
|
||||||
cat > package.json <<EOF
|
cp ${src}/package.json .
|
||||||
{
|
chmod 644 package.json
|
||||||
"name": "${packageName}",
|
|
||||||
"version": "${version}"
|
# Pinpoint the versions of all dependencies to the ones that are actually being used
|
||||||
}
|
echo "pinpointing versions of dependencies..."
|
||||||
EOF
|
cd ..
|
||||||
|
source $pinpointDependenciesScriptPath
|
||||||
|
cd ${packageName}
|
||||||
|
|
||||||
# Patch the shebangs of the bundled modules to prevent them from
|
# Patch the shebangs of the bundled modules to prevent them from
|
||||||
# calling executables outside the Nix store as much as possible
|
# calling executables outside the Nix store as much as possible
|
||||||
patchShebangs .
|
patchShebangs .
|
||||||
|
|
||||||
export HOME=$PWD
|
export HOME=$PWD
|
||||||
|
|
||||||
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"} rebuild
|
||||||
|
|
||||||
${stdenv.lib.optionalString (!dontNpmInstall) ''
|
${stdenv.lib.optionalString (!dontNpmInstall) ''
|
||||||
@ -321,6 +321,8 @@ let
|
|||||||
npm --registry http://www.example.com --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
|
npm --registry http://www.example.com --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
|
||||||
''}
|
''}
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
mv ${packageName} lib
|
||||||
ln -s $out/lib/node_modules/.bin $out/bin
|
ln -s $out/lib/node_modules/.bin $out/bin
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user