protoc-gen-grpc-java: init at 1.73.0 (#415329)

This commit is contained in:
Petr Portnov | PROgrm_JARvis
2025-06-15 16:35:33 +02:00
committed by GitHub
parent 1bfcb1539b
commit dbae6575d6
3 changed files with 134 additions and 0 deletions
@@ -0,0 +1,11 @@
{
linux-aarch_64 = "sha256-sgdZoaSM7LgK4DbbKPJO3FdBA37YAX86meaKDLQiOmg=";
linux-ppcle_64 = "sha256-k4nQGJNwtd8W4nJLyWPRhqjikczy7p7ffDIrWxkcUTA=";
linux-s390_64 = "sha256-fcuNlJeUmduFzqt5WaefYk3lFVmdHeSFIEkbwT2I1O0=";
linux-x86_32 = "sha256-KNvqGkeERd2UxzhjO/Fp6Uv7DGBt15rPGviRmH7pmno=";
linux-x86_64 = "sha256-7LI115E3BOz3jnHavkQBbN0hsjKuSbnXNAjXFw/D14I=";
osx-aarch_64 = "sha256-gAo2bcsivjDVFX5cUvzngoHgqTAPt+3Hiuynd17/KTo=";
osx-x86_64 = "sha256-gAo2bcsivjDVFX5cUvzngoHgqTAPt+3Hiuynd17/KTo=";
windows-x86_32 = "sha256-ERbksXFy4AFhZSFG9G4AMOi68EzEScBvDJFF9+rnPnU=";
windows-x86_64 = "sha256-wZU6on7A84fPm8xwD8pBgSk8+fkB14LdvWZXEniz8LU=";
}
@@ -0,0 +1,90 @@
{
lib,
stdenv,
fetchurl,
makeWrapper,
autoPatchelfHook,
}:
let
hostArch =
let
platform = stdenv.hostPlatform;
os =
if platform.isLinux then
"linux"
else if platform.isDarwin then
"osx"
else if platform.isWindows then
"windows"
else
throw "Unsupoprted OS \"${platform.parsed.kernel.name}\"";
arch =
if platform.isx86_32 then
"x86_32"
else if platform.isx86_64 then
"x86_64"
else if platform.isAarch64 then
"aarch_64"
else if platform.isPower64 && platform.isLittleEndian then
"ppcle_64"
else if platform.isS390x then
"s390_64"
else
throw "Unsupported CPU \"${platform.parsed.cpu.name}\"";
in
"${os}-${arch}";
in
stdenv.mkDerivation (finalAttrs: {
pname = "protoc-gen-grpc-java";
version = "1.73.0";
src = fetchurl {
url = "https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/${finalAttrs.version}/protoc-gen-grpc-java-${finalAttrs.version}-${hostArch}.exe";
hash = (import ./hashes.nix).${hostArch} or (throw "Unsuported host arch ${hostArch}");
};
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
nativeBuildInputs = [
makeWrapper
autoPatchelfHook
];
buildInputs = [ stdenv.cc.cc ];
installPhase = ''
runHook preInstall
install -D $src $out/bin/protoc-gen-grpc-java
runHook postInstall
'';
passthru.updateScript = ./update.sh;
meta = {
description = "gRPC Java Codegen Plugin for Protobuf Compiler";
longDescription = ''
This generates the Java interfaces out of the service definition from a `.proto` file.
It works with the Protobuf Compiler (`protoc`).
'';
changelog = "https://github.com/grpc/grpc-java/releases/tag/v${finalAttrs.version}";
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
license = lib.licenses.asl20;
maintainers = [ lib.maintainers.progrm_jarvis ];
homepage = "https://grpc.io/docs/languages/java/generated-code/";
platforms = [
# Linux
"x86_64-linux"
"i686-linux"
"aarch64-linux"
"powerpc64le-linux"
"s390x-linux"
# Darwin
"x86_64-darwin"
"aarch64-darwin"
# Windows
"x86_64-windows"
"i686-windows"
];
};
})
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq gnused nix
set -euo pipefail
ARCHS=(
'linux-aarch_64'
'linux-ppcle_64'
'linux-s390_64'
'linux-x86_32'
'linux-x86_64'
'osx-aarch_64'
'osx-x86_64'
'windows-x86_32'
'windows-x86_64'
)
HASHES_FILE=pkgs/by-name/pr/protoc-gen-grpc-java/hashes.nix
version="$(
curl --silent --location --fail \
${GITHUB_TOKEN:+-u ":${GITHUB_TOKEN}"} \
https://api.github.com/repos/grpc/grpc-java/releases/latest |
jq -r '.tag_name' |
sed 's/^v//'
)"
echo '{' >"${HASHES_FILE}"
for arch in "${ARCHS[@]}"; do
url="https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/${version}/protoc-gen-grpc-java-${version}-${arch}.exe"
hash=$(nix hash convert --hash-algo sha256 --to sri "$(nix-prefetch-url "${url}")")
echo " ${arch} = \"${hash}\";" >>"${HASHES_FILE}"
done
echo '}' >>"${HASHES_FILE}"