about summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorNick Cao <nickcao@nichi.co>2023-12-10 11:58:53 -0500
committerGitHub <noreply@github.com>2023-12-10 11:58:53 -0500
commit56dad982c84426e6370d1f2373d78bbb13620602 (patch)
tree0f91d0a10adb9170659d11a83aa49dcfb27a4852 /nixos/modules
parente2fe29375bcc8cca9ef64a62d3baf578f7746db9 (diff)
parent9c2570f13dd8370685f80e16ca23a5652f3482e4 (diff)
Merge pull request #272654 from NixOS/backport-267906-to-release-23.11
[Backport release-23.11] nixos/keycloak: Allow setting `hostname-url`
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/web-apps/keycloak.nix14
1 files changed, 11 insertions, 3 deletions
diff --git a/nixos/modules/services/web-apps/keycloak.nix b/nixos/modules/services/web-apps/keycloak.nix
index a7e4fab8ea287..c90ee78a3e04b 100644
--- a/nixos/modules/services/web-apps/keycloak.nix
+++ b/nixos/modules/services/web-apps/keycloak.nix
@@ -24,7 +24,6 @@ let
     maintainers
     catAttrs
     collect
-    splitString
     hasPrefix
     ;
 
@@ -335,7 +334,8 @@ in
             };
 
             hostname = mkOption {
-              type = str;
+              type = nullOr str;
+              default = null;
               example = "keycloak.example.com";
               description = lib.mdDoc ''
                 The hostname part of the public URL used as base for
@@ -457,7 +457,7 @@ in
 
       keycloakConfig = lib.generators.toKeyValue {
         mkKeyValue = lib.flip lib.generators.mkKeyValueDefault "=" {
-          mkValueString = v: with builtins;
+          mkValueString = v:
             if isInt v then toString v
             else if isString v then v
             else if true == v then "true"
@@ -486,6 +486,14 @@ in
             assertion = createLocalPostgreSQL -> config.services.postgresql.settings.standard_conforming_strings or true;
             message = "Setting up a local PostgreSQL db for Keycloak requires `standard_conforming_strings` turned on to work reliably";
           }
+          {
+            assertion = cfg.settings.hostname != null || cfg.settings.hostname-url or null != null;
+            message = "Setting the Keycloak hostname is required, see `services.keycloak.settings.hostname`";
+          }
+          {
+            assertion = !(cfg.settings.hostname != null && cfg.settings.hostname-url or null != null);
+            message = "`services.keycloak.settings.hostname` and `services.keycloak.settings.hostname-url` are mutually exclusive";
+          }
         ];
 
         environment.systemPackages = [ keycloakBuild ];