All three derivations verified on ringtail (nixos-25.11): - client-go: Go API client generated and formatted with gofmt - client-ts: TypeScript fetch client generated and compiled with tsc - api-go-vendor-hook: setup hook built successfully Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2.7 KiB
2.7 KiB
| title | modified | tags | |||
|---|---|---|---|---|---|
| Generate Authentik API Clients | 2026-02-28 |
|
Generate Authentik API Clients
Build Go and TypeScript API client bindings from authentik's OpenAPI spec (schema.yml). These are build-time inputs for the Go server and web UI respectively.
Context
Authentik maintains a separate repo (goauthentik/client-go) with pre-generated Go client code. The nixpkgs derivation fetches this and injects it into the Go vendor directory via a setup hook (apiGoVendorHook). The TypeScript client is generated inline from schema.yml using openapi-generator-cli.
Both clients are generated from the same schema.yml OpenAPI spec in the main authentik repo.
What to Do
- Create a Nix derivation (
client-go) that generates Go API client bindings fromschema.ymlusingopenapi-generator-cli - Create a Nix derivation (
client-ts) that generates TypeScript fetch client bindings from the same spec - Create a setup hook (
apiGoVendorHook) that replacesgoauthentik.io/api/v3in the Go vendor directory with the generated client - Verify the generated code compiles (Go:
go build, TypeScript: type-check withtsc)
Key Details
- Source spec:
schema.ymlin the authentik repo root - Go client replaces
vendor/goauthentik.io/api/v3/in the server build - TypeScript client replaces
web/node_modules/@goauthentik/api/in the web UI build - The
client-go-config.patchaddsdisallowAdditionalPropertiesIfNotPresent: falseto the OpenAPI generator config — still needed as of 2025.12.4
What We Learned
- The Go client source comes from
goauthentik/client-go(separate repo), not the main authentik repo. It containsschema.yml,config.yaml,go.mod, andgo.sum. - The TypeScript client uses the main authentik source's
schema.ymlandscripts/api/ts-config.yaml. - The
apiGoVendorHookmust skip itself during FOD builds (checking$outputHash) so the GovendorHashonly depends ongo.sum, not generated client content. - Both clients build cleanly on nixos-25.11 with
openapi-generator-cli7.17.0.
Files
containers/authentik/client-go.nix— Go client derivationcontainers/authentik/client-ts.nix— TypeScript client derivationcontainers/authentik/api-go-vendor-hook.nix— Go vendor injection hookcontainers/authentik/client-go-config.patch— OpenAPI generator config patchcontainers/authentik/source.nix— Shared version and source fetch
Related
- build-authentik-from-source — Parent goal
- authentik-go-server-derivation — Consumer of Go client
- authentik-web-ui-derivation — Consumer of TypeScript client