From 1d0cbbbd94f969dc8a8bc96284bba17e96ca81a0 Mon Sep 17 00:00:00 2001 From: kurogeek Date: Fri, 24 Oct 2025 16:49:17 +0700 Subject: [PATCH] mob next [ci-skip] [ci skip] [skip ci] lastFile:modules/clan/phonebox/tests/vm/default.nix --- modules/clan/asterisk/default.nix | 3 - modules/clan/phonebox/default.nix | 128 +++++++++++++++++++++ modules/clan/phonebox/flake-module.nix | 18 +++ modules/clan/phonebox/tests/vm/default.nix | 39 +++++++ 4 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 modules/clan/phonebox/default.nix create mode 100644 modules/clan/phonebox/flake-module.nix create mode 100644 modules/clan/phonebox/tests/vm/default.nix diff --git a/modules/clan/asterisk/default.nix b/modules/clan/asterisk/default.nix index 78b1dbc..663c199 100644 --- a/modules/clan/asterisk/default.nix +++ b/modules/clan/asterisk/default.nix @@ -15,9 +15,6 @@ networking.firewall.allowedUDPPorts = [ 5060 ]; services.asterisk = { enable = lib.mkDefault true; - extraArguments = [ - "-vvvddd" - ]; confFiles = { "logger.conf" = '' [general] diff --git a/modules/clan/phonebox/default.nix b/modules/clan/phonebox/default.nix new file mode 100644 index 0000000..b4e7b89 --- /dev/null +++ b/modules/clan/phonebox/default.nix @@ -0,0 +1,128 @@ +{ ... }: +{ + _class = "clan.service"; + manifest.name = "phonebox"; + manifest.description = ""; + manifest.categories = [ "System" ]; + + roles.default = { + perInstance.nixosModule = + { + lib, + ... + }: + { + networking.firewall.allowedUDPPorts = [ 5060 ]; + services.asterisk = { + enable = lib.mkDefault true; + confFiles = { + "logger.conf" = '' + [general] + dateformat = %F %T.%3q ; ISO 8601 date format with milliseconds + use_callids = yes + appendhostname = no + queue_log = yes + queue_log_to_file = no + queue_log_name = queue_log + queue_log_realtime_use_gmt = no + rotatestrategy = rotate + exec_after_rotate=gzip -9 $\{filename\}.2 + [logfiles] + console => notice,warning,error + security => security + messages => notice,warning,error + full => notice,warning,error,verbose,dtmf,fax + syslog.local0 => notice,warning,error + ''; + # Dial plan config + "extensions.conf" = '' + [from-internal] + exten => 100,1,Answer() + same => n,Wait(1) + same => n,Playback(hello-world) + same => n,Hangup() + + exten => 6001,1,Dial(PJSIP/6001,20) + exten => 6002,1,Dial(PJSIP/6002,20) + exten => 8001,1,Dial(PJSIP/8001@kurogeek,20) + ''; + + "pjsip.conf" = '' + [transport-udp] + type=transport + protocol=udp + bind=0.0.0.0 + [transport-udp6] + type=transport + protocol=udp + bind=:: + + [kurogeek] + type=endpoint + context=from-kurogeek + disallow=all + allow=ulaw + allow=alaw + allow=g722 + allow=gsm + aors=kurogeek + direct_media=no + + [kurogeek] + type=aor + contact=sip:[fd79:fada:fbe9:8c5d:d899:932b:d36d:b8cc] + + [kurogeek] + type=identify + endpoint=kurogeek + match=[fd79:fada:fbe9:8c5d:d899:932b:d36d:b8cc] + + [6001] + type=endpoint + context=from-internal + disallow=all + allow=ulaw + allow=alaw + allow=g722 + allow=gsm + auth=6001 + aors=6001 + direct_media=no + + [6001] + type=auth + auth_type=userpass + password=unsecurepassword + username=6001 + + [6001] + type=aor + max_contacts=1 + + [6002] + type=endpoint + context=from-internal + disallow=all + allow=ulaw + allow=alaw + allow=g722 + allow=gsm + auth=6002 + aors=6002 + direct_media=no + + [6002] + type=auth + auth_type=userpass + password=unsecurepassword + username=6002 + + [6002] + type=aor + max_contacts=1 + ''; + }; + }; + }; + }; +} diff --git a/modules/clan/phonebox/flake-module.nix b/modules/clan/phonebox/flake-module.nix new file mode 100644 index 0000000..2b04186 --- /dev/null +++ b/modules/clan/phonebox/flake-module.nix @@ -0,0 +1,18 @@ +{ lib, ... }: +let + module = lib.modules.importApply ./default.nix { }; +in +{ + clan.modules = { + phonebox = module; + }; + perSystem = + { ... }: + { + clan.nixosTests.phonebox = { + imports = [ ./tests/vm/default.nix ]; + + clan.modules."@clan/phonebox" = module; + }; + }; +} diff --git a/modules/clan/phonebox/tests/vm/default.nix b/modules/clan/phonebox/tests/vm/default.nix new file mode 100644 index 0000000..f371c1d --- /dev/null +++ b/modules/clan/phonebox/tests/vm/default.nix @@ -0,0 +1,39 @@ +{ + pkgs, + ... +}: +{ + name = "service-phonebox"; + + clan = { + directory = ./.; + inventory = { + machines.server = { }; + + instances = { + phonebox-test = { + module.name = "@clan/phonebox"; + module.input = "self"; + roles.default.machines."server".settings = { }; + }; + }; + }; + }; + + nodes = { + server = { + services.asterisk = { + }; + }; + }; + + testScript = '' + start_all() + + server.wait_for_unit("asterisk") + + # Check that garage is running + server.succeed("systemctl status asterisk") + + ''; +}