···11+# shellcheck shell=bash
22+33+iplConfigHook() {
44+ echo "Executing iplConfigHook"
55+66+ if ! command -v "pnpm" &> /dev/null; then
77+ echo "Error: 'pnpm' binary not found in PATH. Consider adding 'pkgs.pnpm' to 'nativeBuildInputs'." >&2
88+ exit 1
99+ fi
1010+1111+ export HOME=$(mktemp -d)
1212+ export npm_config_arch="@npmArch@"
1313+ export npm_config_platform="@npmPlatform@"
1414+1515+ # If the packageManager field in package.json is set to a different pnpm version than what is in nixpkgs,
1616+ # any pnpm command would fail in that directory, the following disables this
1717+ pushd /
1818+ pnpm config set manage-package-manager-versions false
1919+ popd
2020+2121+ pnpm config set store-dir "$STORE_PATH"
2222+2323+ # Prevent hard linking on file systems without clone support.
2424+ # See: https://pnpm.io/settings#packageimportmethod
2525+ pnpm config set package-import-method clone-or-copy
2626+2727+ # mitm-cache doesn't set a full URL and pnpm defaults to https. Force it to treat it as a plain text proxy
2828+ pnpm config set https-proxy "http://$https_proxy"
2929+3030+ runHook prePnpmInstall
3131+3232+ if ! pnpm install \
3333+ --ignore-scripts \
3434+ "${pnpmInstallFlags[@]}" \
3535+ --frozen-lockfile
3636+ then
3737+ echo
3838+ echo "ERROR: pnpm failed to install dependencies"
3939+ echo
4040+4141+ exit 1
4242+ fi
4343+4444+ echo "Patching scripts"
4545+4646+ patchShebangs node_modules/{*,.*}
4747+4848+ echo "Finished iplConfigHook"
4949+}
5050+5151+postConfigureHooks+=(iplConfigHook)
5252+