blumeops/containers/authentik/client-go.nix

47 lines
966 B
Nix
Raw Permalink Normal View History

C2: Build authentik from source (Mikado chain) (#274) ## Mikado Chain: build-authentik-from-source Replace `pkgs.authentik` from nixpkgs with a custom Nix derivation built from source. This removes the dependency on the nixpkgs packaging timeline and gives full version control. Target version: **2025.12.4** (nixpkgs reference, upgrading from deployed 2025.10.1). ### Dependency Graph ``` build-authentik-from-source (goal) ├── authentik-go-server-derivation │ ├── authentik-api-client-generation ← IN PROGRESS │ └── authentik-python-backend-derivation ├── authentik-web-ui-derivation │ └── authentik-api-client-generation ← IN PROGRESS └── authentik-python-backend-derivation ``` ### Ready Leaves - `authentik-api-client-generation` — Go + TypeScript client generation from OpenAPI schema - `authentik-python-backend-derivation` — Django backend with 60+ deps, 4 in-tree packages ### Architecture Ported from [nixpkgs `pkgs/by-name/au/authentik/package.nix`](https://github.com/NixOS/nixpkgs/tree/master/pkgs/by-name/au/authentik): - `source.nix` — shared version/source fetch - `client-go.nix` — Go API client generation - `client-ts.nix` — TypeScript API client generation - `api-go-vendor-hook.nix` — Go vendor directory injection hook - (more components to follow as leaves are closed) ### Related Cards - [[build-authentik-from-source]] — Goal card - [[authentik-api-client-generation]] - [[authentik-python-backend-derivation]] - [[authentik-web-ui-derivation]] - [[authentik-go-server-derivation]] Reviewed-on: https://forge.ops.eblu.me/eblume/blumeops/pulls/274
2026-03-01 13:45:00 -08:00
# Generate Go API client bindings from authentik's OpenAPI schema
# Uses openapi-generator-cli to produce Go code from schema.yml
{ pkgs ? import <nixpkgs> { }, sources ? import ./sources.nix { inherit pkgs; } }:
pkgs.stdenvNoCC.mkDerivation {
pname = "authentik-client-go";
version = "3.${sources.version}";
inherit (sources) meta;
src = sources.client-go-src;
# Docker volume path /local → local pwd
postPatch = ''
substituteInPlace ./config.yaml \
--replace-fail '/local' "$(pwd)"
'';
nativeBuildInputs = with pkgs; [
openapi-generator-cli
go
];
buildPhase = ''
runHook preBuild
openapi-generator-cli generate \
-i ${sources.src}/schema.yml -o $out \
-g go \
-c ./config.yaml
gofmt -w $out
runHook postBuild
'';
installPhase = ''
runHook preInstall
cp go.mod go.sum $out
cd $out
rm -rf test
rm -f .travis.yml git_push.sh
runHook postInstall
'';
}