From 067c1958fa35b2b994944da7f4fe3fc7f326e418 Mon Sep 17 00:00:00 2001 From: Ruby Iris Juric Date: Sat, 30 Dec 2023 13:02:17 +1100 Subject: [PATCH 1/4] protoc-gen-js: init at 3.21.2 --- pkgs/by-name/pr/protoc-gen-js/package.nix | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pkgs/by-name/pr/protoc-gen-js/package.nix diff --git a/pkgs/by-name/pr/protoc-gen-js/package.nix b/pkgs/by-name/pr/protoc-gen-js/package.nix new file mode 100644 index 000000000000..21cd426388f8 --- /dev/null +++ b/pkgs/by-name/pr/protoc-gen-js/package.nix @@ -0,0 +1,37 @@ +{ stdenv, lib, buildBazelPackage, bazel_6, fetchFromGitHub, darwin }: + +buildBazelPackage rec { + pname = "protoc-gen-js"; + version = "3.21.2"; + + src = fetchFromGitHub { + owner = "protocolbuffers"; + repo = "protobuf-javascript"; + rev = "v${version}"; + hash = "sha256-TmP6xftUVTD7yML7UEM/DB8bcsL5RFlKPyCpcboD86U="; + }; + + bazel = bazel_6; + bazelTargets = [ "generator:protoc-gen-js" ]; + bazelBuildFlags = lib.optionals stdenv.cc.isClang [ "--cxxopt=-x" "--cxxopt=c++" "--host_cxxopt=-x" "--host_cxxopt=c++" ]; + removeRulesCC = false; + removeLocalConfigCC = false; + + LIBTOOL = lib.optionalString stdenv.isDarwin "${darwin.cctools}/bin/libtool"; + + fetchAttrs.sha256 = "sha256-H0zTMCMFct09WdR/mzcs9FcC2OU/ZhGye7GAkx4tGa8="; + + buildAttrs.installPhase = '' + mkdir -p $out/bin + install -Dm755 bazel-bin/generator/protoc-gen-js $out/bin/ + ''; + + meta = with lib; { + description = "Protobuf plugin for generating JavaScript code"; + homepage = "https://github.com/protocolbuffers/protobuf-javascript"; + platforms = platforms.linux ++ platforms.darwin; + license = with licenses; [ asl20 bsd3 ]; + sourceProvenance = [ sourceTypes.fromSource ]; + maintainers = with maintainers; [ Sorixelle ]; + }; +} From dd38622bab55b9eb96ecc26f0be5d38ee1b89fe0 Mon Sep 17 00:00:00 2001 From: Ruby Iris Juric Date: Sat, 30 Dec 2023 13:19:24 +1100 Subject: [PATCH 2/4] 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 ]; From 4504f46b9c22dbb3841e461da8b106094e6df2cb Mon Sep 17 00:00:00 2001 From: Ruby Iris Juric Date: Sat, 30 Dec 2023 13:32:47 +1100 Subject: [PATCH 3/4] zitadel: 2.40.3 -> 2.42.10 --- pkgs/by-name/zi/zitadel/console.nix | 4 ++-- pkgs/by-name/zi/zitadel/package.json | 17 ++++++++++------- pkgs/by-name/zi/zitadel/package.nix | 8 ++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pkgs/by-name/zi/zitadel/console.nix b/pkgs/by-name/zi/zitadel/console.nix index bd67c47e5743..163ed7aded29 100644 --- a/pkgs/by-name/zi/zitadel/console.nix +++ b/pkgs/by-name/zi/zitadel/console.nix @@ -23,7 +23,7 @@ let workDir = "console"; bufArgs = "../proto --include-imports --include-wkt"; outputPath = "src/app/proto"; - hash = "sha256-Bpoe1UZGLTxUqdLbvOod6/77R4CsYQ4PirMfqvI9Lz8="; + hash = "sha256-h/5K6PvEFyjzS5p7SfuDIk91TkN1iPc+iXor8T/QSeE="; }; in mkYarnPackage rec { @@ -35,7 +35,7 @@ mkYarnPackage rec { packageJSON = ./package.json; offlineCache = fetchYarnDeps { yarnLock = "${src}/yarn.lock"; - hash = "sha256-rSKoIznYVDNgrBmut7YSxNhgPJnbIeO+/s0HnrYWPUc="; + hash = "sha256-cfo2WLSbfU8tYADjF7j9zTLNsboVThF6MUBrb49MrII="; }; postPatch = '' diff --git a/pkgs/by-name/zi/zitadel/package.json b/pkgs/by-name/zi/zitadel/package.json index 5819fdd77aed..42dc0ef19d77 100644 --- a/pkgs/by-name/zi/zitadel/package.json +++ b/pkgs/by-name/zi/zitadel/package.json @@ -25,8 +25,11 @@ "@angular/router": "^16.2.5", "@angular/service-worker": "^16.2.5", "@ctrl/ngx-codemirror": "^6.1.0", + "@fortawesome/angular-fontawesome": "^0.13.0", + "@fortawesome/fontawesome-svg-core": "^6.4.2", + "@fortawesome/free-brands-svg-icons": "^6.4.2", "@grpc/grpc-js": "^1.9.3", - "@ngx-translate/core": "^14.0.0", + "@ngx-translate/core": "^15.0.0", "angular-oauth2-oidc": "^15.0.1", "angularx-qrcode": "^16.0.0", "buffer": "^6.0.3", @@ -34,18 +37,18 @@ "cors": "^2.8.5", "file-saver": "^2.0.5", "flag-icons": "^6.7.0", - "google-proto-files": "^3.0.3", + "google-proto-files": "^4.0.0", "google-protobuf": "^3.21.2", "grpc-web": "^1.4.1", "i18n-iso-countries": "^7.6.0", - "libphonenumber-js": "^1.10.30", + "libphonenumber-js": "^1.10.49", "material-design-icons-iconfont": "^6.1.1", "moment": "^2.29.4", "ngx-color": "^9.0.0", "opentype.js": "^1.3.4", "rxjs": "~7.8.0", "tinycolor2": "^1.6.0", - "tslib": "^2.4.1", + "tslib": "^2.6.2", "uuid": "^9.0.0", "zone.js": "~0.13.1" }, @@ -60,11 +63,11 @@ "@angular/compiler-cli": "^16.2.5", "@angular/language-service": "^16.2.5", "@bufbuild/buf": "^1.23.1", - "@types/file-saver": "^2.0.2", + "@types/file-saver": "^2.0.7", "@types/google-protobuf": "^3.15.3", "@types/jasmine": "~4.3.6", "@types/jasminewd2": "~2.0.10", - "@types/jsonwebtoken": "^9.0.1", + "@types/jsonwebtoken": "^9.0.5", "@types/node": "^20.7.0", "@types/opentype.js": "^1.3.4", "@types/qrcode": "^1.5.2", @@ -83,6 +86,6 @@ "prettier": "^3.0.3", "prettier-plugin-organize-imports": "^3.2.2", "protractor": "~7.0.0", - "typescript": "^4.9.5" + "typescript": "^5.1.6" } } diff --git a/pkgs/by-name/zi/zitadel/package.nix b/pkgs/by-name/zi/zitadel/package.nix index aa2a0be622eb..08078ad4066f 100644 --- a/pkgs/by-name/zi/zitadel/package.nix +++ b/pkgs/by-name/zi/zitadel/package.nix @@ -15,14 +15,14 @@ }: let - version = "2.40.3"; + version = "2.42.10"; zitadelRepo = fetchFromGitHub { owner = "zitadel"; repo = "zitadel"; rev = "v${version}"; - hash = "sha256-WqsK6DAYkLs5wBNvkVGarLMm/unBLtipFkl07pR90HI="; + hash = "sha256-Uv0iEIFkTdBAi0WDBQHf0ATs4L2FOU4NmiE9p1MHSa0="; }; - goModulesHash = "sha256-IVf1YVnhyEYgZqM31Cv3aBFnPG7v5WW6fCEvlN+sTIE="; + goModulesHash = "sha256-PQch046YjYhAmVlNNdgDLWIqFvEpXRgXAYFMwSZmk4w="; buildZitadelProtocGen = name: buildGo121Module { @@ -92,7 +92,7 @@ let protoc-gen-zitadel ]; outputPath = ".artifacts"; - hash = "sha256-xrEF1B4pMoCZs1WO9F6IoqHnSyt5BhPVTIABMWK/q2E="; + hash = "sha256-3qDVY2CvtY8lZDr+p5i0vV6zZ5KyTtxBLyV7Os9KuIw="; }; in buildGo121Module rec { From a95da94f9aae7c543b538bbb991222465605159a Mon Sep 17 00:00:00 2001 From: Ruby Iris Juric Date: Sat, 30 Dec 2023 13:49:01 +1100 Subject: [PATCH 4/4] zitadel: use preBuild instead of overriding buildPhase --- pkgs/by-name/zi/zitadel/package.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/zi/zitadel/package.nix b/pkgs/by-name/zi/zitadel/package.nix index 08078ad4066f..e8118b463ef2 100644 --- a/pkgs/by-name/zi/zitadel/package.nix +++ b/pkgs/by-name/zi/zitadel/package.nix @@ -105,10 +105,11 @@ buildGo121Module rec { proxyVendor = true; vendorHash = goModulesHash; + ldflags = [ "-X 'github.com/zitadel/zitadel/cmd/build.version=${version}'" ]; # Adapted from Makefile in repo, with dependency fetching and protobuf codegen # bits removed - buildPhase = '' + preBuild = '' mkdir -p pkg/grpc cp -r ${protobufGenerated}/grpc/github.com/zitadel/zitadel/pkg/grpc/* pkg/grpc mkdir -p openapi/v2/zitadel @@ -123,12 +124,13 @@ buildGo121Module rec { go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=docs/apis/assets/assets.md cp -r ${passthru.console}/* internal/api/ui/console/static - CGO_ENABLED=0 go build -o zitadel -v -ldflags="-s -w -X 'github.com/zitadel/zitadel/cmd/build.version=${version}'" ''; + doCheck = false; + installPhase = '' mkdir -p $out/bin - install -Dm755 zitadel $out/bin/ + install -Dm755 $GOPATH/bin/zitadel $out/bin/ ''; passthru = {