yarnConfigHook: init

This commit is contained in:
Doron Behar 2024-06-07 16:18:21 +03:00
parent 1151b39c24
commit a84f3ca3d8
3 changed files with 52 additions and 0 deletions

View File

@ -7,6 +7,9 @@
fetchurl,
nodejs-slim,
prefetch-yarn-deps,
fixup-yarn-lock,
yarn,
makeSetupHook,
cacert,
callPackage,
nix,
@ -154,4 +157,15 @@ in
);
in
lib.setFunctionArgs f (lib.functionArgs f) // { inherit tests; };
yarnConfigHook = makeSetupHook {
name = "yarn-config-hook";
propagatedBuildInputs = [
yarn
fixup-yarn-lock
];
meta = {
description = "Install nodejs dependencies from an offline yarn cache produced by fetchYarnDeps";
};
} ./yarn-config-hook.sh;
}

View File

@ -0,0 +1,37 @@
yarnConfigHook(){
runHook preConfigure
echo "Executing yarnConfigHook"
# Use a constant HOME directory
mkdir -p /tmp/home
export HOME=/tmp/home
if [[ -n "$yarnOfflineCache" ]]; then
offlineCache="$yarnOfflineCache"
fi
if [[ -z "$offlineCache" ]]; then
echo yarnConfigHook: No yarnOfflineCache or offlineCache were defined\! >&2
exit 2
fi
yarn config --offline set yarn-offline-mirror "$offlineCache"
fixup-yarn-lock yarn.lock
yarn install \
--frozen-lockfile \
--force \
--production=false \
--ignore-engines \
--ignore-platform \
--ignore-scripts \
--no-progress \
--non-interactive \
--offline
# TODO: Check if this is really needed
patchShebangs node_modules
echo "finished yarnConfigHook"
runHook postConfigure
}
if [[ -z "${dontYarnInstallDeps-}" && -z "${configurePhase-}" ]]; then
configurePhase=yarnConfigHook
fi

View File

@ -986,6 +986,7 @@ with pkgs;
inherit (callPackages ../build-support/node/fetch-yarn-deps { })
fixup-yarn-lock
prefetch-yarn-deps
yarnConfigHook
fetchYarnDeps;
find-cursor = callPackage ../tools/X11/find-cursor { };