mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: add ability to include custom protoc-gen-go dependency in nix flake (#14728)
This commit is contained in:
@@ -5,6 +5,20 @@ set -eu
|
||||
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
check_and_install() {
|
||||
if ! command -v "$1" &>/dev/null; then
|
||||
echo "$1 is not installed. Attempting to install..."
|
||||
if ! nix-env -iA nixpkgs."$1"; then
|
||||
echo "Failed to install $1. Please install it manually and try again."
|
||||
exit 1
|
||||
fi
|
||||
echo "$1 has been installed successfully."
|
||||
fi
|
||||
}
|
||||
|
||||
check_and_install jq
|
||||
check_and_install nix-prefetch-git
|
||||
|
||||
OUT=$(mktemp -d -t nar-hash-XXXXXX)
|
||||
|
||||
echo "Downloading Go modules..."
|
||||
@@ -13,4 +27,14 @@ echo "Calculating SRI hash..."
|
||||
HASH=$(go run tailscale.com/cmd/nardump --sri "$OUT/pkg/mod/cache/download")
|
||||
sudo rm -rf "$OUT"
|
||||
|
||||
echo "Updating go.mod vendorHash"
|
||||
sed -i "s#\(vendorHash = \"\)[^\"]*#\1${HASH}#" ./flake.nix
|
||||
|
||||
# Update protoc-gen-go sha256
|
||||
echo "Updating protoc-gen-go sha256..."
|
||||
PROTOC_GEN_GO_REV=$(nix eval --extra-experimental-features nix-command --extra-experimental-features flakes --raw .#proto_gen_go.rev)
|
||||
echo "protoc-gen-go version: $PROTOC_GEN_GO_REV"
|
||||
PROTOC_GEN_GO_SHA256=$(nix-prefetch-git https://github.com/protocolbuffers/protobuf-go --rev "$PROTOC_GEN_GO_REV" | jq -r .hash)
|
||||
sed -i "s#\(sha256 = \"\)[^\"]*#\1${PROTOC_GEN_GO_SHA256}#" ./flake.nix
|
||||
|
||||
echo "Flake updated successfully!"
|
||||
|
||||
Reference in New Issue
Block a user