mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 15:33:13 +00:00
elm.elmPackages: Update elm-analyse and node2nix
This commit is contained in:
parent
e449caf606
commit
3b1948b2d4
@ -56,7 +56,7 @@ let
|
|||||||
*/
|
*/
|
||||||
elm-test = patchBinwrap [elmi-to-json] elmNodePackages.elm-test;
|
elm-test = patchBinwrap [elmi-to-json] elmNodePackages.elm-test;
|
||||||
elm-verify-examples = patchBinwrap [elmi-to-json] elmNodePackages.elm-verify-examples;
|
elm-verify-examples = patchBinwrap [elmi-to-json] elmNodePackages.elm-verify-examples;
|
||||||
elm-analyse = elmNodePackages."elm-analyse-0.16.3";
|
elm-analyse = elmNodePackages.elm-analyse;
|
||||||
inherit (elmNodePackages) elm-doc-preview elm-upgrade;
|
inherit (elmNodePackages) elm-doc-preview elm-upgrade;
|
||||||
};
|
};
|
||||||
in elmPkgs // {
|
in elmPkgs // {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# This file has been generated by node2nix 1.6.0. Do not edit!
|
# This file has been generated by node2nix 1.7.0. Do not edit!
|
||||||
|
|
||||||
{pkgs ? import <nixpkgs> {
|
{pkgs ? import <nixpkgs> {
|
||||||
inherit system;
|
inherit system;
|
||||||
|
@ -11,7 +11,7 @@ let
|
|||||||
|
|
||||||
cat > $out/bin/tar <<EOF
|
cat > $out/bin/tar <<EOF
|
||||||
#! ${stdenv.shell} -e
|
#! ${stdenv.shell} -e
|
||||||
$(type -p tar) "\$@" --warning=no-unknown-keyword
|
$(type -p tar) "\$@" --warning=no-unknown-keyword --delay-directory-restore
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod +x $out/bin/tar
|
chmod +x $out/bin/tar
|
||||||
@ -72,7 +72,7 @@ let
|
|||||||
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
packageDir="$(find . -maxdepth 1 -type d | tail -1)"
|
||||||
|
|
||||||
# Restore write permissions to make building work
|
# Restore write permissions to make building work
|
||||||
find "$packageDir" -type d -print0 | xargs -0 chmod u+x
|
find "$packageDir" -type d -exec chmod u+x {} \;
|
||||||
chmod -R u+w "$packageDir"
|
chmod -R u+w "$packageDir"
|
||||||
|
|
||||||
# Move the extracted tarball into the output folder
|
# Move the extracted tarball into the output folder
|
||||||
@ -219,7 +219,16 @@ let
|
|||||||
packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
|
packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
|
||||||
}
|
}
|
||||||
|
|
||||||
packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
|
if(dependency.resolved) {
|
||||||
|
packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided
|
||||||
|
} else {
|
||||||
|
packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dependency.from !== undefined) { // Adopt from property if one has been provided
|
||||||
|
packageObj["_from"] = dependency.from;
|
||||||
|
}
|
||||||
|
|
||||||
fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
|
fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,50 +317,11 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
# Builds and composes an NPM package including all its dependencies
|
prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
|
||||||
buildNodePackage =
|
|
||||||
{ name
|
|
||||||
, packageName
|
|
||||||
, version
|
|
||||||
, dependencies ? []
|
|
||||||
, buildInputs ? []
|
|
||||||
, production ? true
|
|
||||||
, npmFlags ? ""
|
|
||||||
, dontNpmInstall ? false
|
|
||||||
, bypassCache ? false
|
|
||||||
, preRebuild ? ""
|
|
||||||
, dontStrip ? true
|
|
||||||
, unpackPhase ? "true"
|
|
||||||
, buildPhase ? "true"
|
|
||||||
, ... }@args:
|
|
||||||
|
|
||||||
let
|
let
|
||||||
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
|
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
|
||||||
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation ({
|
''
|
||||||
name = "node-${name}-${version}";
|
|
||||||
buildInputs = [ tarWrapper python nodejs ]
|
|
||||||
++ stdenv.lib.optional (stdenv.isLinux) utillinux
|
|
||||||
++ stdenv.lib.optional (stdenv.isDarwin) libtool
|
|
||||||
++ buildInputs;
|
|
||||||
|
|
||||||
inherit dontStrip; # Stripping may fail a build for some package deployments
|
|
||||||
inherit dontNpmInstall preRebuild unpackPhase buildPhase;
|
|
||||||
|
|
||||||
compositionScript = composePackage args;
|
|
||||||
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
|
||||||
|
|
||||||
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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
|
||||||
@ -375,11 +345,18 @@ let
|
|||||||
runHook preRebuild
|
runHook preRebuild
|
||||||
|
|
||||||
${stdenv.lib.optionalString bypassCache ''
|
${stdenv.lib.optionalString bypassCache ''
|
||||||
if [ ! -f package-lock.json ]
|
${stdenv.lib.optionalString reconstructLock ''
|
||||||
then
|
if [ -f package-lock.json ]
|
||||||
echo "No package-lock.json file found, reconstructing..."
|
then
|
||||||
node ${reconstructPackageLock}
|
echo "WARNING: Reconstruct lock option enabled, but a lock file already exists!"
|
||||||
fi
|
echo "This will most likely result in version mismatches! We will remove the lock file and regenerate it!"
|
||||||
|
rm package-lock.json
|
||||||
|
else
|
||||||
|
echo "No package-lock.json file found, reconstructing..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
node ${reconstructPackageLock}
|
||||||
|
''}
|
||||||
|
|
||||||
node ${addIntegrityFieldsScript}
|
node ${addIntegrityFieldsScript}
|
||||||
''}
|
''}
|
||||||
@ -393,6 +370,53 @@ let
|
|||||||
|
|
||||||
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
|
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
|
||||||
fi
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Builds and composes an NPM package including all its dependencies
|
||||||
|
buildNodePackage =
|
||||||
|
{ name
|
||||||
|
, packageName
|
||||||
|
, version
|
||||||
|
, dependencies ? []
|
||||||
|
, buildInputs ? []
|
||||||
|
, production ? true
|
||||||
|
, npmFlags ? ""
|
||||||
|
, dontNpmInstall ? false
|
||||||
|
, bypassCache ? false
|
||||||
|
, reconstructLock ? false
|
||||||
|
, preRebuild ? ""
|
||||||
|
, dontStrip ? true
|
||||||
|
, unpackPhase ? "true"
|
||||||
|
, buildPhase ? "true"
|
||||||
|
, ... }@args:
|
||||||
|
|
||||||
|
let
|
||||||
|
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" ];
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation ({
|
||||||
|
name = "node_${name}-${version}";
|
||||||
|
buildInputs = [ tarWrapper python nodejs ]
|
||||||
|
++ stdenv.lib.optional (stdenv.isLinux) utillinux
|
||||||
|
++ stdenv.lib.optional (stdenv.isDarwin) libtool
|
||||||
|
++ buildInputs;
|
||||||
|
|
||||||
|
inherit dontStrip; # Stripping may fail a build for some package deployments
|
||||||
|
inherit dontNpmInstall preRebuild unpackPhase buildPhase;
|
||||||
|
|
||||||
|
compositionScript = composePackage args;
|
||||||
|
pinpointDependenciesScript = pinpointDependenciesOfPackage args;
|
||||||
|
|
||||||
|
passAsFile = [ "compositionScript" "pinpointDependenciesScript" ];
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
# 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
|
||||||
|
|
||||||
|
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
|
||||||
|
|
||||||
# Create symlink to the deployed executable folder, if applicable
|
# Create symlink to the deployed executable folder, if applicable
|
||||||
if [ -d "$out/lib/node_modules/.bin" ]
|
if [ -d "$out/lib/node_modules/.bin" ]
|
||||||
@ -431,14 +455,13 @@ let
|
|||||||
, npmFlags ? ""
|
, npmFlags ? ""
|
||||||
, dontNpmInstall ? false
|
, dontNpmInstall ? false
|
||||||
, bypassCache ? false
|
, bypassCache ? false
|
||||||
|
, reconstructLock ? false
|
||||||
, dontStrip ? true
|
, dontStrip ? true
|
||||||
, unpackPhase ? "true"
|
, unpackPhase ? "true"
|
||||||
, buildPhase ? "true"
|
, buildPhase ? "true"
|
||||||
, ... }@args:
|
, ... }@args:
|
||||||
|
|
||||||
let
|
let
|
||||||
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
|
|
||||||
|
|
||||||
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
|
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
|
||||||
|
|
||||||
nodeDependencies = stdenv.mkDerivation ({
|
nodeDependencies = stdenv.mkDerivation ({
|
||||||
@ -473,39 +496,13 @@ let
|
|||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
# Pinpoint the versions of all dependencies to the ones that are actually being used
|
# Go to the parent folder to make sure that all packages are pinpointed
|
||||||
echo "pinpointing versions of dependencies..."
|
|
||||||
cd ..
|
cd ..
|
||||||
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
||||||
|
|
||||||
source $pinpointDependenciesScriptPath
|
${prepareAndInvokeNPM { inherit packageName bypassCache reconstructLock npmFlags production; }}
|
||||||
cd ${packageName}
|
|
||||||
|
|
||||||
# Patch the shebangs of the bundled modules to prevent them from
|
|
||||||
# calling executables outside the Nix store as much as possible
|
|
||||||
patchShebangs .
|
|
||||||
|
|
||||||
export HOME=$PWD
|
|
||||||
|
|
||||||
${stdenv.lib.optionalString bypassCache ''
|
|
||||||
if [ ! -f package-lock.json ]
|
|
||||||
then
|
|
||||||
echo "No package-lock.json file found, reconstructing..."
|
|
||||||
node ${reconstructPackageLock}
|
|
||||||
fi
|
|
||||||
|
|
||||||
node ${addIntegrityFieldsScript}
|
|
||||||
''}
|
|
||||||
|
|
||||||
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} rebuild
|
|
||||||
|
|
||||||
${stdenv.lib.optionalString (!dontNpmInstall) ''
|
|
||||||
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
|
|
||||||
rm -f npm-shrinkwrap.json
|
|
||||||
|
|
||||||
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${stdenv.lib.optionalString production "--production"} install
|
|
||||||
''}
|
|
||||||
|
|
||||||
|
# Expose the executables that were installed
|
||||||
cd ..
|
cd ..
|
||||||
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
|
||||||
|
|
||||||
@ -532,6 +529,7 @@ let
|
|||||||
inherit nodeDependencies;
|
inherit nodeDependencies;
|
||||||
shellHook = stdenv.lib.optionalString (dependencies != []) ''
|
shellHook = stdenv.lib.optionalString (dependencies != []) ''
|
||||||
export NODE_PATH=$nodeDependencies/lib/node_modules
|
export NODE_PATH=$nodeDependencies/lib/node_modules
|
||||||
|
export PATH="$nodeDependencies/bin:$PATH"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
"elm-test",
|
"elm-test",
|
||||||
"elm-verify-examples",
|
"elm-verify-examples",
|
||||||
"elm-doc-preview",
|
"elm-doc-preview",
|
||||||
{ "elm-analyse": "0.16.3" },
|
"elm-analyse",
|
||||||
"elm-upgrade"
|
"elm-upgrade"
|
||||||
]
|
]
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user