Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc127d90

Browse files
authored
chore: add ability to include custom protoc-gen-go dependency in nix flake (#14728)
1 parent326886d commitc127d90

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

‎flake.nix

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@
4040
# From https://nixos.wiki/wiki/Google_Cloud_SDK
4141
gdk=pkgs.google-cloud-sdk.withExtraComponents([pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin]);
4242

43+
proto_gen_go_1_30=pkgs.buildGoModulerec{
44+
name="protoc-gen-go";
45+
owner="protocolbuffers";
46+
repo="protobuf-go";
47+
rev="v1.30.0";
48+
src=pkgs.fetchFromGitHub{
49+
owner="protocolbuffers";
50+
repo="protobuf-go";
51+
rev=rev;
52+
# Updated with ./scripts/update-flake.sh`.
53+
sha256="sha256-GTZQ40uoi62Im2F4YvlZWiSNNJ4fEAkRojYa0EYz9HU=";
54+
};
55+
subPackages=["cmd/protoc-gen-go"];
56+
vendorHash=null;
57+
proxyVendor=true;
58+
preBuild=''
59+
export GOPROXY=https://proxy.golang.org,direct
60+
go mod download
61+
'';
62+
};
63+
4364
# The minimal set of packages to build Coder.
4465
devShellPackages=withpkgs;[
4566
# google-chrome is not available on OSX and aarch64 linux
@@ -80,7 +101,7 @@
80101
playwright-driver.browsers
81102
postgresql_16
82103
protobuf
83-
protoc-gen-go
104+
proto_gen_go_1_30
84105
ripgrep
85106
# This doesn't build on latest nixpkgs (July 10 2024)
86107
(pinnedPkgs.sapling)
@@ -117,7 +138,7 @@
117138
name="coder-${osArch}";
118139
# Updated with ./scripts/update-flake.sh`.
119140
# This should be updated whenever go.mod changes!
120-
vendorHash="sha256-KyMqZxav64rbybUUFoBsOlB6XH7y8aQ7ekaYm0QD4Ew=";
141+
vendorHash="sha256-kPXRp7l05iJd4IdvQeOFOgg2UNzBcloy3tA9Meep9VI=";
121142
proxyVendor=true;
122143
src=./.;
123144
nativeBuildInputs=withpkgs;[getoptopensslzstd];
@@ -151,6 +172,7 @@
151172
'';
152173
};
153174
packages={
175+
proto_gen_go=proto_gen_go_1_30;
154176
all=pkgs.buildEnv{
155177
name="all-packages";
156178
paths=devShellPackages;

‎scripts/update-flake.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ set -eu
55

66
cd"$(dirname"${BASH_SOURCE[0]}")/.."
77

8+
check_and_install() {
9+
if!command -v"$1"&>/dev/null;then
10+
echo"$1 is not installed. Attempting to install..."
11+
if! nix-env -iA nixpkgs."$1";then
12+
echo"Failed to install$1. Please install it manually and try again."
13+
exit 1
14+
fi
15+
echo"$1 has been installed successfully."
16+
fi
17+
}
18+
19+
check_and_install jq
20+
check_and_install nix-prefetch-git
21+
822
OUT=$(mktemp -d -t nar-hash-XXXXXX)
923

1024
echo"Downloading Go modules..."
@@ -13,4 +27,14 @@ echo "Calculating SRI hash..."
1327
HASH=$(go run tailscale.com/cmd/nardump --sri"$OUT/pkg/mod/cache/download")
1428
sudo rm -rf"$OUT"
1529

30+
echo"Updating go.mod vendorHash"
1631
sed -i"s#\(vendorHash =\"\)[^\"]*#\1${HASH}#" ./flake.nix
32+
33+
# Update protoc-gen-go sha256
34+
echo"Updating protoc-gen-go sha256..."
35+
PROTOC_GEN_GO_REV=$(nixeval --extra-experimental-features nix-command --extra-experimental-features flakes --raw .#proto_gen_go.rev)
36+
echo"protoc-gen-go version:$PROTOC_GEN_GO_REV"
37+
PROTOC_GEN_GO_SHA256=$(nix-prefetch-git https://github.com/protocolbuffers/protobuf-go --rev"$PROTOC_GEN_GO_REV"| jq -r .hash)
38+
sed -i"s#\(sha256 =\"\)[^\"]*#\1${PROTOC_GEN_GO_SHA256}#" ./flake.nix
39+
40+
echo"Flake updated successfully!"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp