1 Commits

Author SHA1 Message Date
4704dd43fa mob next [ci-skip] [ci skip] [skip ci]
lastFile:modules/clan/asterisk/default.nix
2025-10-21 17:38:54 +07:00
3 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
{ ... }:
{
_class = "clan.service";
manifest.name = "asterisk";
manifest.description = "Asterisk PBX server";
manifest.categories = [ "System" ];
roles.default = {
perInstance.nixosModule =
{
lib,
config,
...
}:
{
services.asterisk = {
enable = lib.mkDefault true;
confFiles = {
"extensions.conf" = ''
[tests]
; Dial 100 for "hello, world"
exten => 100,1,Answer()
same => n,Wait(1)
same => n,Playback(hello-world)
same => n,Hangup()
[softphones]
include => tests
[unauthorized]
'';
"sip.conf" = ''
[general]
allowguest=no ; Require authentication
context=unauthorized ; Send unauthorized users to /dev/null
srvlookup=no ; Don't do DNS lookup
udpbindaddr=0.0.0.0 ; Listen on all interfaces
nat=force_rport,comedia ; Assume device is behind NAT
[softphone](!)
type=friend ; Match on username first, IP second
context=softphones ; Send to softphones context in
; extensions.conf file
host=dynamic ; Device will register with asterisk
disallow=all ; Manually specify codecs to allow
allow=g722
allow=ulaw
allow=alaw
[myphone](softphone)
secret=GhoshevFew ; Change this password!
'';
"logger.conf" = ''
[general]
[logfiles]
; Add debug output to log
syslog.local0 => notice,warning,error,debug
'';
};
};
};
};
}

View File

@@ -0,0 +1,18 @@
{ lib, ... }:
let
module = lib.modules.importApply ./default.nix { };
in
{
clan.modules = {
asterisk = module;
};
perSystem =
{ ... }:
{
clan.nixosTests.asterisk = {
imports = [ ./tests/vm/default.nix ];
clan.modules."@clan/asterisk" = module;
};
};
}

View File

@@ -0,0 +1,39 @@
{
pkgs,
...
}:
{
name = "service-asterisk";
clan = {
directory = ./.;
inventory = {
machines.server = { };
instances = {
asterisk-test = {
module.name = "@clan/asterisk";
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")
'';
}