pkgs: add fetch-node-modules
This commit is contained in:
parent
b214018c29
commit
e63dafe0f7
@ -73,7 +73,13 @@
|
|||||||
nbPkgs = self.lib.mkNbPkgs { inherit system pkgs; };
|
nbPkgs = self.lib.mkNbPkgs { inherit system pkgs; };
|
||||||
in rec {
|
in rec {
|
||||||
packages = flake-utils.lib.flattenTree (removeAttrs nbPkgs [
|
packages = flake-utils.lib.flattenTree (removeAttrs nbPkgs [
|
||||||
"pinned" "modulesPkgs" "nixops19_09" "krops" "generate-secrets" "netns-exec"
|
"fetchNodeModules"
|
||||||
|
"krops"
|
||||||
|
"modulesPkgs"
|
||||||
|
"netns-exec"
|
||||||
|
"nixops19_09"
|
||||||
|
"pinned"
|
||||||
|
"generate-secrets"
|
||||||
]) // {
|
]) // {
|
||||||
inherit (import ./examples/qemu-vm/minimal-vm.nix self pkgs system)
|
inherit (import ./examples/qemu-vm/minimal-vm.nix self pkgs system)
|
||||||
# A simple demo VM.
|
# A simple demo VM.
|
||||||
|
74
pkgs/build-support/fetch-node-modules.nix
Normal file
74
pkgs/build-support/fetch-node-modules.nix
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# This is a modified version of
|
||||||
|
# https://github.com/NixOS/nixpkgs/pull/128749
|
||||||
|
|
||||||
|
{ lib, stdenvNoCC, makeWrapper, nodejs }:
|
||||||
|
|
||||||
|
{ src
|
||||||
|
, hash ? ""
|
||||||
|
, runScripts ? false
|
||||||
|
, preferLocalBuild ? true
|
||||||
|
, npmFlags ? ""
|
||||||
|
, ...
|
||||||
|
} @ args:
|
||||||
|
stdenvNoCC.mkDerivation ({
|
||||||
|
inherit src preferLocalBuild;
|
||||||
|
|
||||||
|
name = "${src.name}-node_modules";
|
||||||
|
nativeBuildInputs = [
|
||||||
|
makeWrapper
|
||||||
|
(if args ? nodejs then args.nodejs else nodejs)
|
||||||
|
];
|
||||||
|
|
||||||
|
outputHashMode = "recursive";
|
||||||
|
|
||||||
|
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
|
||||||
|
|
||||||
|
phases = "unpackPhase patchPhase buildPhase installPhase";
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
if [[ ! -f package.json ]]; then
|
||||||
|
echo "Error: file `package.json` doesn't exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [[ ! -f package-lock.json ]]; then
|
||||||
|
echo "Error: file `package-lock.json` doesn't exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export SOURCE_DATE_EPOCH=1
|
||||||
|
export npm_config_cache=/tmp
|
||||||
|
NPM_FLAGS="--omit=dev --omit=optional --no-update-notifier $npmFlags"
|
||||||
|
# Scripts may result in non-deterministic behavior.
|
||||||
|
# Some packages (e.g., Puppeteer) use postinstall scripts to download extra data.
|
||||||
|
if [[ ! $runScripts ]]; then
|
||||||
|
NPM_FLAGS+=" --ignore-scripts"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running npm ci $NPM_FLAGS"
|
||||||
|
npm ci $NPM_FLAGS
|
||||||
|
|
||||||
|
cp package.json \
|
||||||
|
package-lock.json node_modules/
|
||||||
|
rm -f node_modules/.package-lock.json
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out/lib
|
||||||
|
cp -r node_modules $out/lib
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
} // (
|
||||||
|
if hash == "" then {
|
||||||
|
outputHashAlgo = "sha256";
|
||||||
|
outputHash = "";
|
||||||
|
} else {
|
||||||
|
outputHash = hash;
|
||||||
|
}
|
||||||
|
) // (builtins.removeAttrs args [ "hash" ]))
|
@ -25,6 +25,8 @@ let self = {
|
|||||||
packageOverrides = import ./python-packages self;
|
packageOverrides = import ./python-packages self;
|
||||||
}).pkgs;
|
}).pkgs;
|
||||||
|
|
||||||
|
fetchNodeModules = pkgs.callPackage ./build-support/fetch-node-modules.nix { };
|
||||||
|
|
||||||
# Fix clightning build by using python package mistune 0.8.4, which is a
|
# Fix clightning build by using python package mistune 0.8.4, which is a
|
||||||
# strict requirement. This version is affected by CVE-2022-34749, but this
|
# strict requirement. This version is affected by CVE-2022-34749, but this
|
||||||
# is irrelevant in this context.
|
# is irrelevant in this context.
|
||||||
|
Loading…
Reference in New Issue
Block a user