commonPreStart = ''
# Configure client(s) as "preauthorized"
${concatMapStringsSep "\n\n"
- (attr: ''
- if ! test -e "${statePath}/${attr}.oauth" || [ "$(cat ${statePath}/${attr}.oauth)" != "${cfgIni."${attr}".oauth-client-id}" ]; then
- # Configure ${attr}'s OAuth client as "preauthorized"
- psql ${database} \
- -c "UPDATE oauthclient SET preauthorized = true WHERE client_id = '${cfgIni."${attr}".oauth-client-id}'"
+ (srv: ''
+ if ! test -e "${statePath}/${srv}.oauth" || [ "$(cat ${statePath}/${srv}.oauth)" != "${cfgIni.${srv}.oauth-client-id}" ]; then
+ # Configure ${srv}'s OAuth client as "preauthorized"
+ psql '${database}' \
+ -c "UPDATE oauthclient SET preauthorized = true WHERE client_id = '${cfgIni.${srv}.oauth-client-id}'"
- printf "%s" "${cfgIni."${attr}".oauth-client-id}" > "${statePath}/${attr}.oauth"
+ printf "%s" "${cfgIni.${srv}.oauth-client-id}" > "${statePath}/${srv}.oauth"
fi
'')
- (builtins.attrNames (filterAttrs
- (k: v: !(hasInfix "::" k) && (v.oauth-client-id or null) != null)
- cfg.settings))}
+ (builtins.attrNames (filterAttrs (k: v:
+ let srv = builtins.match "^([a-z]*)\\.sr\\.ht$" k; in
+ srv != null && elem (head srv) cfg.services &&
+ ((v.oauth-client-id or null) != null)
+ ) cfg.settings))}
'';
in {
metasrht = import ./service.nix { inherit config pkgs lib; } scfg drv iniKey {