From 5b7e7cd6a8e26a03e344b0c8e2c20cf549f023c1 Mon Sep 17 00:00:00 2001 From: ibizaman Date: Fri, 14 Oct 2022 22:06:37 -0700 Subject: [PATCH] set keycloak initial admin user through env var --- keycloak/mkunit.nix | 5 ++++- keycloak/unit.nix | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/keycloak/mkunit.nix b/keycloak/mkunit.nix index 8641fd8..150b681 100644 --- a/keycloak/mkunit.nix +++ b/keycloak/mkunit.nix @@ -7,6 +7,7 @@ , group , dbPasswordFile , postgresServiceName +, initialAdminUsername ? "admin" , initialAdminFile ? null , dependsOn ? {} @@ -14,10 +15,12 @@ { inherit name configDir configFile; + inherit initialAdminUsername; + pkg = KeycloakService { inherit configDir configFile; inherit user group; - inherit dbPasswordFile initialAdminFile; + inherit dbPasswordFile initialAdminUsername initialAdminFile; inherit postgresServiceName; }; diff --git a/keycloak/unit.nix b/keycloak/unit.nix index ffc0d2a..eacd94a 100644 --- a/keycloak/unit.nix +++ b/keycloak/unit.nix @@ -10,6 +10,7 @@ , dbType ? "postgres" , dbPasswordFile , postgresServiceName +, initialAdminUsername ? null , initialAdminFile ? null }: { ... }: @@ -39,6 +40,7 @@ utils.systemd.mkService rec { Group=${group} EnvironmentFile=${dbPasswordFile} + ${if initialAdminFile != null then "Environment=KEYCLOAK_ADMIN="+initialAdminUsername else ""} ${if initialAdminFile != null then "EnvironmentFile="+initialAdminFile else ""} Environment=PATH=${pkgs.coreutils}/bin Environment=KC_HOME_DIR="/run/keycloak"