This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

superconfig / pkgs / zitadel / package.nix
5.4 kB 214 lines
1# Based on nixpkgs PR 561044 (https://github.com/NixOS/nixpkgs/pull/561044, 2# zitadel 4.17.3), without the separate Login V2 app. 3{ 4 stdenv, 5 buildGoModule, 6 callPackage, 7 fetchFromGitHub, 8 lib, 9 10 buf, 11 cacert, 12 dart-sass, 13 grpc-gateway, 14 protoc-gen-connect-go, 15 protoc-gen-go, 16 protoc-gen-go-grpc, 17 protoc-gen-validate, 18 statik, 19}: 20 21let 22 version = "4.19.5"; 23 zitadelRepo = fetchFromGitHub { 24 owner = "zitadel"; 25 repo = "zitadel"; 26 tag = "v${version}"; 27 hash = "sha256-FFXsoBlbNTFT1FSxs/IomqTrtNGqsxq9Ck5TSDpSWHM="; 28 }; 29 goModulesHash = "sha256-8/TkV1JTKNSIknzEPbTDWzcOZQ6jCEkc6vSLLhdLYrs="; 30 31 # protoc plugins inside the repository (`go install ./internal/protoc/...` 32 # upstream) 33 buildZitadelProtocGen = 34 name: 35 buildGoModule { 36 pname = "protoc-gen-${name}"; 37 inherit version; 38 39 src = zitadelRepo; 40 41 proxyVendor = true; 42 vendorHash = goModulesHash; 43 44 subPackages = [ "internal/protoc/protoc-gen-${name}" ]; 45 46 doCheck = false; 47 }; 48 49 protoc-gen-authoption = buildZitadelProtocGen "authoption"; 50 protoc-gen-zitadel = buildZitadelProtocGen "zitadel"; 51 52 # Descriptor set of proto/. buf fetches the dependencies pinned in 53 # proto/buf.lock from the Buf Schema Registry, so this is the one 54 # fixed-output step; the code generators run offline against it. 55 protoImage = stdenv.mkDerivation { 56 pname = "zitadel-proto-image"; 57 inherit version; 58 59 src = zitadelRepo; 60 61 nativeBuildInputs = [ 62 buf 63 cacert 64 ]; 65 66 buildPhase = '' 67 runHook preBuild 68 HOME=$TMPDIR buf build proto -o image.binpb 69 runHook postBuild 70 ''; 71 72 installPhase = '' 73 runHook preInstall 74 cp image.binpb $out 75 runHook postInstall 76 ''; 77 78 outputHashMode = "flat"; 79 outputHash = "sha256-vsVaGO6ewwCMkK1Qh/8/JZblwICnszmfZxXAPFIAdOk="; 80 }; 81 82 generateProtobufCode = 83 { 84 pname, 85 version, 86 nativeBuildInputs ? [ ], 87 bufArgs ? "", 88 workDir ? ".", 89 outputPath, 90 }: 91 stdenv.mkDerivation { 92 pname = "${pname}-buf-generated"; 93 inherit version; 94 95 src = zitadelRepo; 96 97 nativeBuildInputs = nativeBuildInputs ++ [ buf ]; 98 99 buildPhase = '' 100 runHook preBuild 101 cd ${workDir} 102 HOME=$TMPDIR buf generate ${protoImage}#format=binpb ${bufArgs} 103 runHook postBuild 104 ''; 105 106 installPhase = '' 107 runHook preInstall 108 cp -r ${outputPath} $out 109 runHook postInstall 110 ''; 111 }; 112 113 jsDeps = callPackage ./javascript.nix { inherit protoImage version zitadelRepo; }; 114 115 # the `generate-stubs` target of apps/api/project.json 116 protobufGenerated = generateProtobufCode { 117 pname = "zitadel"; 118 inherit version; 119 nativeBuildInputs = [ 120 grpc-gateway 121 protoc-gen-authoption 122 protoc-gen-connect-go 123 protoc-gen-go 124 protoc-gen-go-grpc 125 protoc-gen-validate 126 protoc-gen-zitadel 127 ]; 128 outputPath = ".artifacts"; 129 }; 130in 131buildGoModule (finalAttrs: { 132 pname = "zitadel"; 133 inherit version; 134 135 src = zitadelRepo; 136 137 nativeBuildInputs = [ 138 dart-sass 139 statik 140 ]; 141 142 postPatch = '' 143 substituteInPlace internal/api/ui/login/static/resources/generate.go \ 144 --replace-fail "pnpm sass" "sass" 145 ''; 146 147 proxyVendor = true; 148 vendorHash = goModulesHash; 149 ldflags = [ 150 "-s" 151 "-w" 152 "-X 'github.com/zitadel/zitadel/cmd/build.version=${version}'" 153 ]; 154 155 # The other Go packages are docs snippets and test helpers. 156 subPackages = [ "." ]; 157 158 # The generate-stubs, generate-statik, generate-assets and build-console 159 # targets of apps/api/project.json. 160 preBuild = '' 161 # zitadel warns on every invocation without a build date 162 ldflags+=" -X github.com/zitadel/zitadel/cmd/build.date=$(date -u -d "@$SOURCE_DATE_EPOCH" +%Y-%m-%dT%H:%M:%SZ)" 163 164 mkdir -p pkg/grpc 165 cp -r ${protobufGenerated}/grpc/github.com/zitadel/zitadel/pkg/grpc/* pkg/grpc 166 mkdir -p openapi/v2/zitadel 167 cp -r ${protobufGenerated}/grpc/zitadel/ openapi/v2/zitadel 168 169 go generate internal/api/ui/login/static/resources/generate.go 170 go generate internal/api/ui/login/statik/generate.go 171 go generate internal/notification/statik/generate.go 172 go generate internal/statik/generate.go 173 174 mkdir -p apps/docs/content/apis/assets 175 go run internal/api/assets/generator/asset_generator.go \ 176 -directory=internal/api/assets/generator/ \ 177 -assets=apps/docs/content/apis/assets/assets.mdx 178 179 find internal/api/ui/console/static -mindepth 1 ! -name gitkeep -delete 180 cp -r ${finalAttrs.passthru.console}/* internal/api/ui/console/static 181 ''; 182 183 doCheck = false; 184 185 installPhase = '' 186 runHook preInstall 187 install -Dm755 $GOPATH/bin/zitadel $out/bin/zitadel 188 runHook postInstall 189 ''; 190 191 passthru = { 192 console = callPackage (import ./console.nix { 193 inherit 194 generateProtobufCode 195 jsDeps 196 version 197 zitadelRepo 198 ; 199 }) { }; 200 inherit protoImage; 201 inherit (jsDeps) pnpmDeps; 202 }; 203 204 meta = { 205 description = "Identity and access management platform"; 206 homepage = "https://zitadel.com/"; 207 downloadPage = "https://github.com/zitadel/zitadel/releases"; 208 changelog = "https://github.com/zitadel/zitadel/releases/tag/v${version}"; 209 platforms = lib.platforms.linux ++ lib.platforms.darwin; 210 license = lib.licenses.agpl3Only; 211 sourceProvenance = [ lib.sourceTypes.fromSource ]; 212 mainProgram = "zitadel"; 213 }; 214})