tvl-depot/nix/buildBazelPackageNG/bazelRulesNodeJS5Hook/setup-hook.sh
Luke Granger-Brown c05bf02a85 chore(3p/gerrit): create buildBazelPackageNG and migrate gerrit to it
This bumps Gerrit to 3.10.0, and also introduces a new mechanism for
building it that should hopefully have some more stable hashes than the
previous bodgery.

In this world, we only cache what we explicitly want to. There are some
hooks implemented for `rules_java` and `rules_nodejs` (before version
6) that force use of local binaries; this means we can drop the use of
the FHSUserEnv and use the java and nodejs binaries provided by nixpkgs
instead.

detzip is deleted; it hasn't been used in yonks.

We also add https://gerrit-review.googlesource.com/c/gerrit/+/431977,
which bumps the SSHd version so that we can have U2F-based SSH keys.

Change-Id: Ie12a9a33bbb1e4bd96aa252580aca3b8bc4a1205
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11963
Reviewed-by: lukegb <lukegb@tvl.fyi>
Autosubmit: lukegb <lukegb@tvl.fyi>
Tested-by: BuildkiteCI
2024-07-08 00:17:56 +00:00

63 lines
1.9 KiB
Bash

prePatchHooks+=(_setupLocalNodeRepos)
preBuildHooks+=(_setupYarnCache)
case "$bazelPhase" in
cache)
postInstallHooks+=(_copyYarnCache)
;;
build)
preBuildHooks+=(_linkYarnCache)
;;
*)
echo "Unexpected bazelPhase '$bazelPhase' (want cache or build)" >&2
exit 1
;;
esac
_setupLocalNodeRepos() {
cp -R @local_node@ $HOME/local_node
chmod -R +w $HOME/local_node
substituteInPlace $HOME/local_node/bin/node \
--replace-fail '__NODEJS__' '@nodejs@'
substituteInPlace $HOME/local_node/bin/npm \
--replace-fail '__NODEJS__' '@nodejs@'
substituteInPlace $HOME/local_node/BUILD \
--replace-fail '__NODEJS__' '@nodejs@'
chmod -R +x $HOME/local_node/bin/*
cp -R @local_yarn@ $HOME/local_yarn
chmod -R +w $HOME/local_yarn
substituteInPlace $HOME/local_yarn/bin/yarn \
--replace-fail '__YARN__' '@yarn@'
chmod -R +x $HOME/local_yarn/bin/*
bazelFlagsArray+=(
"--override_repository=build_bazel_rules_nodejs=@rulesNodeJS@"
"--override_repository=nodejs_linux_amd64=$HOME/local_node"
"--override_repository=nodejs_linux_arm64=$HOME/local_node"
"--override_repository=nodejs_linux_s390x=$HOME/local_node"
"--override_repository=nodejs_linux_ppc64le=$HOME/local_node"
"--override_repository=nodejs_darwin_amd64=$HOME/local_node"
"--override_repository=nodejs_darwin_arm64=$HOME/local_node"
"--override_repository=nodejs_windows_amd64=$HOME/local_node"
"--override_repository=nodejs_windows_arm64=$HOME/local_node"
"--override_repository=nodejs=$HOME/local_node"
"--override_repository=yarn=$HOME/local_yarn"
)
}
_setupYarnCache() {
@yarn@/bin/yarn config set cafile "@cacert@/etc/ssl/certs/ca-bundle.crt"
@yarn@/bin/yarn config set yarn-offline-mirror "$HOME/yarn-offline-mirror"
}
_copyYarnCache() {
cp -R "$HOME/yarn-offline-mirror" "$out/yarn-offline-mirror"
}
_linkYarnCache() {
ln -sf "$cache/yarn-offline-mirror" "$HOME/yarn-offline-mirror"
}