nixpkgs/pkgs/build-support/node/fetch-yarn-deps/yarn-config-hook.sh
seth 278e1bfb89
yarnConfigHook: apply as a postConfigure hook
This follows in this example of npmConfigHook and allows for using this
hook alongside others that may override configurePhase
2024-08-28 23:30:55 -04:00

36 lines
918 B
Bash

yarnConfigHook(){
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"
}
if [[ -z "${dontYarnInstallDeps-}" ]]; then
postConfigureHooks+=(yarnConfigHook)
fi