From dd38622bab55b9eb96ecc26f0be5d38ee1b89fe0 Mon Sep 17 00:00:00 2001 From: Ruby Iris Juric Date: Sat, 30 Dec 2023 13:19:24 +1100 Subject: [PATCH] zitadel: use local plugins for console protobuf generation Previously, the console portion of ZITADEL used Buf remote plugins to generate sources. This resulted in the hash for the protobuf generated code changing whenever the remote builders changed. This change patches the console configuration to use local plugins from Nixpkgs instead of remote ones, to ensure the output isn't influenced by remote changes. --- .../console-use-local-protobuf-plugins.patch | 21 +++++++++++++++++++ pkgs/by-name/zi/zitadel/console.nix | 11 +++++++++- pkgs/by-name/zi/zitadel/package.nix | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 pkgs/by-name/zi/zitadel/console-use-local-protobuf-plugins.patch diff --git a/pkgs/by-name/zi/zitadel/console-use-local-protobuf-plugins.patch b/pkgs/by-name/zi/zitadel/console-use-local-protobuf-plugins.patch new file mode 100644 index 000000000000..4babb92b25f9 --- /dev/null +++ b/pkgs/by-name/zi/zitadel/console-use-local-protobuf-plugins.patch @@ -0,0 +1,21 @@ +diff --git a/console/buf.gen.yaml b/console/buf.gen.yaml +index 1737c2ded..d6affa8bc 100644 +--- a/console/buf.gen.yaml ++++ b/console/buf.gen.yaml +@@ -3,12 +3,12 @@ version: v1 + managed: + enabled: true + plugins: +- - plugin: buf.build/protocolbuffers/js ++ - plugin: js + out: src/app/proto/generated + opt: import_style=commonjs,binary +- - plugin: buf.build/grpc/web ++ - plugin: grpc-web + out: src/app/proto/generated + opt: import_style=typescript,mode=grpcweb +- - plugin: buf.build/grpc-ecosystem/openapiv2 ++ - plugin: openapiv2 + out: src/app/proto/generated + opt: allow_delete_body +\ No newline at end of file diff --git a/pkgs/by-name/zi/zitadel/console.nix b/pkgs/by-name/zi/zitadel/console.nix index b9ec209dda73..bd67c47e5743 100644 --- a/pkgs/by-name/zi/zitadel/console.nix +++ b/pkgs/by-name/zi/zitadel/console.nix @@ -6,15 +6,24 @@ { mkYarnPackage , fetchYarnDeps , lib + +, grpc-gateway +, protoc-gen-grpc-web +, protoc-gen-js }: let protobufGenerated = generateProtobufCode { pname = "zitadel-console"; + nativeBuildInputs = [ + grpc-gateway + protoc-gen-grpc-web + protoc-gen-js + ]; workDir = "console"; bufArgs = "../proto --include-imports --include-wkt"; outputPath = "src/app/proto"; - hash = "sha256-NmlKjKWxmqatyR6OitlQ7bfl6U6PS6KWqTALwX42HS4="; + hash = "sha256-Bpoe1UZGLTxUqdLbvOod6/77R4CsYQ4PirMfqvI9Lz8="; }; in mkYarnPackage rec { diff --git a/pkgs/by-name/zi/zitadel/package.nix b/pkgs/by-name/zi/zitadel/package.nix index 03216c406209..aa2a0be622eb 100644 --- a/pkgs/by-name/zi/zitadel/package.nix +++ b/pkgs/by-name/zi/zitadel/package.nix @@ -62,6 +62,7 @@ let name = "${pname}-buf-generated"; src = zitadelRepo; + patches = [ ./console-use-local-protobuf-plugins.patch ]; nativeBuildInputs = nativeBuildInputs ++ [ buf ];