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

chore: add ability to include custom protoc-gen-go dependency in nix flake#14728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dannykopping merged 6 commits intocoder:mainfromjoobisb:fix/flake-dep
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
updated flake script
  • Loading branch information
@joobisb
joobisb committedSep 20, 2024
commit29e30cbcbfcda7fd28f1736740f232d24c49d01f
5 changes: 2 additions & 3 deletionsflake.nix
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,8 +49,7 @@
owner = "protocolbuffers";
repo = "protobuf-go";
rev = rev;
# This should be updated whenever rev changes!
# To update, set to "", run nix-shell, insert new hash
# Updated with ./scripts/update-flake.sh`.
sha256 = "sha256-GTZQ40uoi62Im2F4YvlZWiSNNJ4fEAkRojYa0EYz9HU=";
};
subPackages = [ "cmd/protoc-gen-go" ];
Expand DownExpand Up@@ -139,7 +138,7 @@
name = "coder-${osArch}";
# Updated with ./scripts/update-flake.sh`.
# This should be updated whenever go.mod changes!
vendorHash = "sha256-KyMqZxav64rbybUUFoBsOlB6XH7y8aQ7ekaYm0QD4Ew=";
vendorHash = "sha256-biJ4rUJ0lmWqUQLAg0QqyIAaLuZ7e//+loWJIefnrNw=";
proxyVendor = true;
src = ./.;
nativeBuildInputs = with pkgs; [ getopt openssl zstd ];
Expand Down
24 changes: 24 additions & 0 deletionsscripts/update-flake.sh
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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..."
Expand All@@ -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=$(grep -A 20 'pkgs.buildGoModule rec' flake.nix | grep -A 10 'repo = "protobuf-go"' | grep 'rev = "v' | sed 's/.*rev = "\(.*\)".*/\1/')
Copy link
Contributor

@dannykoppingdannykoppingSep 20, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is flimsy (and possibly not portable across Linux/Mac/Windows); is there a more robust way we can get this?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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!"
Loading

[8]ページ先頭

©2009-2025 Movatter.jp