@@ -5,8 +5,17 @@ Make NixOS services **more declaratively configurable** than upstream Nixpkgs
55modules allow, by pairing each service with its Terraform provider and
66reconciling the service's _ runtime state_ once it is up.
77
8- > ** Status:** the pattern is implemented and the ** Forgejo pairing is the
9- > worked reference** (see [ ` services/forgejo ` ] ( services/forgejo/README.md ) ).
8+ > ** Status:** two pairings implemented.
9+ >
10+ > - ** [ Forgejo] ( services/forgejo/README.md ) ** — 15 resource types
11+ > (organizations, users, repositories, teams, action secrets/variables,
12+ > webhooks, branch protection, SSH/GPG/deploy keys, collaborators).
13+ > - ** [ Keycloak] ( services/keycloak/README.md ) ** — ~ 95 resource types
14+ > (realms, clients, scopes, ~ 20 protocol mappers, identity providers,
15+ > IdP mappers, roles, groups, users, authentication flows, fine-grained
16+ > authorization + policies, LDAP federation + mappers, realm keystores,
17+ > realm-level config). Includes a service-account bootstrap and nested
18+ > ` <attr>File ` indirection for every secret attribute at any depth.
1019
1120## The gap this closes
1221
@@ -32,6 +41,24 @@ services.forgejo = {
3241 };
3342 };
3443};
44+
45+ services.keycloak = {
46+ enable = true;
47+ initialAdminPassword = "REPLACE_ME";
48+ database.passwordFile = "/run/secrets/keycloak-db-password";
49+ runtime = {
50+ enable = true;
51+ bootstrapAdminPasswordFile = "/run/secrets/keycloak-admin-password";
52+ realms.staff.display_name = "Staff SSO";
53+ openid_clients.app = {
54+ realm = "staff";
55+ client_id = "app";
56+ access_type = "CONFIDENTIAL";
57+ client_secretFile = "/run/secrets/staff-app-client-secret";
58+ valid_redirect_uris = [ "https://app.example.com/*" ];
59+ };
60+ };
61+ };
3562```
3663
3764A pairing only makes sense when a service has ** admin-declarative runtime state
@@ -54,11 +81,15 @@ unit_ visibly (`systemctl status`) without tearing down the service.
5481## Usage
5582
5683Add this flake as an input and import the pairing's NixOS module
57- (` nixosModules.forgejo ` , or ` nixosModules.default ` for all pairings). Full
58- installation, configuration examples, the option reference, the resource table,
59- and the secrets guide live in the per-pairing README:
84+ (` nixosModules.forgejo ` , ` nixosModules.keycloak ` , or
85+ ` nixosModules.default ` for all pairings). Full installation, configuration
86+ examples, the option reference, the resource table, and the secrets guide
87+ live in the per-pairing README:
6088
6189- [ Forgejo pairing] ( services/forgejo/README.md )
90+ - [ Keycloak pairing] ( services/keycloak/README.md ) — includes the
91+ service-account bootstrap flow and the operator-supplied client
92+ override.
6293
6394### Secrets
6495
@@ -72,18 +103,23 @@ path — prefer it over the literal for any real secret.
72103## Repository layout
73104
74105```
75- flake.nix # outputs: nixosModules, checks, formatter
76- treefmt.nix # treefmt + nixfmt config
106+ flake.nix # outputs: nixosModules, checks, formatter
107+ treefmt.nix # treefmt + nixfmt config
77108modules/
78- default.nix # aggregates per-pairing modules into nixosModules.default
79- lib/ # provider-agnostic helpers: tf-label/file, run-once reconciler
80- services/ # one directory per service<->provider pairing
81- forgejo/ # the worked Forgejo <-> svalabs/forgejo pairing
82- module.nix # NixOS module: services.forgejo.runtime + systemd wiring
83- lib.nix # provider specifics: wrapped executor + .tf.json generation
84- pkg.nix # vendor the provider (not in nixpkgs)
85- checks.nix # NixOS VM test
86- README.md # usage docs
109+ default.nix # aggregates per-pairing modules into nixosModules.default
110+ lib/ # shared helpers: tf-label/file, run-once reconciler
111+ services/ # one directory per service<->provider pairing
112+ forgejo/ # Forgejo <-> svalabs/forgejo
113+ module.nix # NixOS module: services.forgejo.runtime + systemd wiring
114+ lib.nix # provider specifics: wrapped executor + .tf.json generation
115+ pkg.nix # vendor the provider (not in nixpkgs)
116+ checks.nix # NixOS VM test
117+ README.md # usage docs
118+ keycloak/ # Keycloak <-> keycloak/keycloak (in nixpkgs)
119+ module.nix # services.keycloak.runtime + reconciler + bootstrap unit
120+ lib.nix # ~95 typed resourceTypes + the value-tree renderer
121+ checks.nix # 1 VM + 4 nspawn-container tests, one per resource family
122+ README.md # usage docs
87123```
88124
89125## Development
0 commit comments