Skip to content

Commit b510085

Browse files
authored
Merge pull request #1900 from gabyx/fix/keycloak-realm-links
fix: keycloak: error out on missing symlinks
2 parents 668a50d + f49e794 commit b510085

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/modules/services/keycloak.nix

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,20 @@ in
334334

335335
# Generate the command to import realms.
336336
realmImport = lib.mapAttrsToList
337-
(realm: e: ''
338-
echo "Symlinking realm file '${e.path}' to import path '$KC_HOME_DIR/data/import'."
339-
ln -fs "${config.env.DEVENV_ROOT + "/" + e.path}" "$KC_HOME_DIR/data/import/"
340-
'')
337+
(
338+
realm: e:
339+
let
340+
f = config.env.DEVENV_ROOT + "/" + e.path;
341+
in
342+
''
343+
echo "Symlinking realm file '${f}' to import path '$KC_HOME_DIR/data/import'."
344+
if [ ! -f "${f}" ]; then
345+
echo "Realm file '${f}' does not exist!" >&2
346+
exit 1
347+
fi
348+
ln -fs "${f}" "$KC_HOME_DIR/data/import/"
349+
''
350+
)
341351
(lib.filterAttrs (_: v: v.import && v.path != null) cfg.realms);
342352

343353
# Generate the command to export realms.

0 commit comments

Comments
 (0)