From 31b0c5789a188dc3900711d9370350ee0a636324 Mon Sep 17 00:00:00 2001 From: Jan-Henrik Bruhn Date: Tue, 7 Apr 2026 09:19:47 +0200 Subject: [PATCH] feat: enable person lines that are not connected to the single shared line --- modules/voip/asterisk/default.nix | 8 ++++++-- modules/voip/dashboard.nix | 2 +- modules/voip/options.nix | 9 +++++++++ modules/voip/phones.nix | 2 ++ modules/voip/provisioning/default.nix | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/voip/asterisk/default.nix b/modules/voip/asterisk/default.nix index 6bf9431..065f7b1 100644 --- a/modules/voip/asterisk/default.nix +++ b/modules/voip/asterisk/default.nix @@ -42,14 +42,18 @@ let # Shared phones (no personal mailbox) and sip-clients use L1 for everything. phoneHasL2 = key: let phone = allPhones.${key}; - in phone.personKey != null && models.${phone.model}.hasMultiLine; + in phone.personKey != null && phone.sharedLine && models.${phone.model}.hasMultiLine; # Dial target: L2 for provisioned phones, L1 for sip-clients (can only register once) dialTarget = key: if phoneHasL2 key then "PJSIP/${key}-l2" else "PJSIP/${key}"; # Dial target strings + # L2 endpoints for "all" DID routing: shared phones (always) + persons with sharedLine = true allL2Endpoints = lib.concatStringsSep "&" - (map dialTarget (lib.attrNames allPhones)); + (map dialTarget + (lib.attrNames (lib.filterAttrs (_: phone: + phone.personKey == null || phone.sharedLine + ) allPhones))); personL1Endpoints = personKey: lib.concatStringsSep "&" diff --git a/modules/voip/dashboard.nix b/modules/voip/dashboard.nix index 1b45e9c..5b7d43a 100644 --- a/modules/voip/dashboard.nix +++ b/modules/voip/dashboard.nix @@ -20,7 +20,7 @@ let # Whether a phone gets an L2 line (same logic as asterisk.nix) phoneHasL2 = key: let phone = allPhones.${key}; - in phone.personKey != null && models.${phone.model}.hasMultiLine; + in phone.personKey != null && phone.sharedLine && models.${phone.model}.hasMultiLine; # ── Nodes ─────────────────────────────────────────────────────────────── diff --git a/modules/voip/options.nix b/modules/voip/options.nix index 3823e65..68c6245 100644 --- a/modules/voip/options.nix +++ b/modules/voip/options.nix @@ -82,6 +82,15 @@ in { default = ""; description = "Name shown in the directory and on caller ID."; }; + sharedLine = lib.mkOption { + type = lib.types.bool; + default = true; + description = '' + Whether this person's phones participate in the shared/family line (L2). + Set to false for persons who should only be reachable on their personal + extension and must not appear in "all" DID routing. + ''; + }; mailbox = lib.mkOption { type = lib.types.bool; default = true; diff --git a/modules/voip/phones.nix b/modules/voip/phones.nix index 2468cc5..33be46e 100644 --- a/modules/voip/phones.nix +++ b/modules/voip/phones.nix @@ -62,6 +62,7 @@ let extension = p.extension; displayName = p.displayName; personKey = null; + sharedLine = true; # shared phones always participate in shared line mailboxExt = null; # shared phones have no personal mailbox }) cfg.sharedPhones // @@ -71,6 +72,7 @@ let extension = person.extension; displayName = person.displayName; personKey = personKey; + sharedLine = person.sharedLine; mailboxExt = if person.mailbox then person.extension else null; }) person.phones ) {} cfg.persons; diff --git a/modules/voip/provisioning/default.nix b/modules/voip/provisioning/default.nix index f7de96a..6609c38 100644 --- a/modules/voip/provisioning/default.nix +++ b/modules/voip/provisioning/default.nix @@ -40,7 +40,7 @@ pkgs.linkFarm "voip-tftp-root" ( lib.optionals m.hasProvisioning ( let t = templates.${phone.model}; - familyLineEnabled = hasTrunk && phone.personKey != null; + familyLineEnabled = hasTrunk && phone.personKey != null && phone.sharedLine; intercomLineIndex = if familyLineEnabled then 3 else 2; files = t.mkFiles ({