20 lines
659 B
Nix
20 lines
659 B
Nix
{ lib, cfg, models }:
|
|
|
|
if cfg.intercomPrefix == null then []
|
|
else lib.concatLists (lib.mapAttrsToList (key: phone:
|
|
let
|
|
m = models.${phone.model};
|
|
ext = phone.extension;
|
|
# cfg.extensions.${ext} is guaranteed to exist by the phone→extension assertion
|
|
extCfg = cfg.extensions.${ext};
|
|
in lib.optional m.hasProvisioning {
|
|
extension = "${cfg.intercomPrefix}${ext}";
|
|
endpoint = "${key}-intercom";
|
|
phoneKey = key;
|
|
target = ext;
|
|
displayName = "Intercom ${extCfg.displayName}";
|
|
password = phone.password;
|
|
endpointTemplate = m.endpointTemplate;
|
|
maxContacts = m.maxContacts;
|
|
}
|
|
) cfg.phones)
|