19 zitadelRepo = fetchFromGitHub {
23 hash = "sha256-RXcJwGO8OQ38lbuy2uLTSkh6yUbyqY42FpwgMXC3g6c=";
25 goModulesHash = "sha256-gp17dP67HX7Tx3Gq+kEu9xCYkfs/rGpqLFiKT7cKlrc=";
27 buildZitadelProtocGen = name:
29 pname = "protoc-gen-${name}";
35 vendorHash = goModulesHash;
38 go install internal/protoc/protoc-gen-${name}/main.go
42 mv $out/bin/main $out/bin/protoc-gen-${name}
46 protoc-gen-authoption = buildZitadelProtocGen "authoption";
47 protoc-gen-zitadel = buildZitadelProtocGen "zitadel";
49 # Buf downloads dependencies from an external repo - there doesn't seem to
50 # really be any good way around it. We'll use a fixed-output derivation so it
51 # can download what it needs, and output the relevant generated code for use
52 # during the main build.
53 generateProtobufCode =
55 , nativeBuildInputs ? [ ]
62 name = "${pname}-buf-generated";
65 patches = [ ./console-use-local-protobuf-plugins.patch ];
67 nativeBuildInputs = nativeBuildInputs ++ [ buf cacert ];
71 HOME=$TMPDIR buf generate ${bufArgs}
75 cp -r ${outputPath} $out
78 outputHashMode = "recursive";
79 outputHashAlgo = "sha256";
83 protobufGenerated = generateProtobufCode {
93 outputPath = ".artifacts";
94 hash = "sha256-KRf11PNn7LtVFjG3NYUtPEJtLNbnxfzR4B69US07B3k=";
103 nativeBuildInputs = [ sass statik ];
106 vendorHash = goModulesHash;
107 ldflags = [ "-X 'github.com/zitadel/zitadel/cmd/build.version=${version}'" ];
109 # Adapted from Makefile in repo, with dependency fetching and protobuf codegen
113 cp -r ${protobufGenerated}/grpc/github.com/zitadel/zitadel/pkg/grpc/* pkg/grpc
114 mkdir -p openapi/v2/zitadel
115 cp -r ${protobufGenerated}/grpc/zitadel/ openapi/v2/zitadel
117 go generate internal/api/ui/login/static/resources/generate.go
118 go generate internal/api/ui/login/statik/generate.go
119 go generate internal/notification/statik/generate.go
120 go generate internal/statik/generate.go
122 mkdir -p docs/apis/assets
123 go run internal/api/assets/generator/asset_generator.go -directory=internal/api/assets/generator/ -assets=docs/apis/assets/assets.md
125 cp -r ${passthru.console}/* internal/api/ui/console/static
132 install -Dm755 $GOPATH/bin/zitadel $out/bin/
136 console = callPackage
137 (import ./console.nix {
138 inherit generateProtobufCode version zitadelRepo;
144 description = "Identity and access management platform";
145 homepage = "https://zitadel.com/";
146 downloadPage = "https://github.com/zitadel/zitadel/releases";
147 platforms = platforms.linux ++ platforms.darwin;
148 license = licenses.asl20;
149 sourceProvenance = [ sourceTypes.fromSource ];
150 maintainers = [ maintainers.nrabulinski ];