2 Commits

Author SHA1 Message Date
f6e3b7509c mob next [ci-skip] [ci skip] [skip ci]
lastFile:vars/per-machine/rigel/yggdrasil/yggdrasil-secret/secret
2025-10-22 16:42:00 +07:00
7115a93a0b clanService asterisk 2025-10-22 16:40:59 +07:00
5 changed files with 147 additions and 8 deletions

View File

@@ -60,6 +60,13 @@
roles.default.tags."fax-bridge" = { }; roles.default.tags."fax-bridge" = { };
}; };
asterisk = {
module = {
name = "asterisk";
input = "self";
};
};
pocket-id = { pocket-id = {
module = { module = {
name = "pocket-id"; name = "pocket-id";

View File

@@ -1,5 +1,9 @@
{ lib, config, ... }:
let let
ata-interface = "enp2s0"; ata-interface = "enp2s0";
ipv6Subnet = lib.elemAt (lib.splitString "/" config.clan.core.vars.generators.yggdrasil.files.yggdrasil-subnet.value) 0;
ipv6Prefix = lib.elemAt (lib.splitString "/" config.clan.core.vars.generators.yggdrasil.files.yggdrasil-subnet.value) 1;
in in
{ {
# clan.core.vars.generators.networking.files.ata-interface.secret = false; # clan.core.vars.generators.networking.files.ata-interface.secret = false;
@@ -15,17 +19,15 @@ in
]; ];
ipv6.addresses = [ ipv6.addresses = [
{ {
address = "fdab:c002:36cb::1"; address = ipv6Subnet + "1";
prefixLength = 64; prefixLength = lib.toInt ipv6Prefix;
} }
]; ];
ipv6.routes = [ ipv6.routes = [
{ {
address = "fdab:c002:36cb::"; address = "200::";
prefixLength = 64; prefixLength = 7;
} # via = "${ipv6Subnet}1";
{
address = "";
} }
]; ];
}; };
@@ -45,7 +47,7 @@ in
domain = "localhost"; domain = "localhost";
dhcp-range = [ dhcp-range = [
"192.168.254.10,192.168.254.240,255.255.255.0,24h" "192.168.254.10,192.168.254.240,255.255.255.0,24h"
"fdab:c002:36cb::10,fdab:c002:36cb::240,slaac" "${ipv6Subnet}10,${ipv6Subnet}240,slaac"
]; ];
dhcp-option = [ dhcp-option = [
"3,192.168.254.1" "3,192.168.254.1"
@@ -67,6 +69,10 @@ in
}; };
}; };
boot.kernel.sysctl = {
"net.ipv6.conf.all.forwarding" = true;
};
networking.firewall.allowedUDPPorts = [ networking.firewall.allowedUDPPorts = [
53 53
67 67

View File

@@ -0,0 +1,69 @@
{ ... }:
{
_class = "clan.service";
manifest.name = "asterisk";
manifest.description = "Asterisk PBX server";
manifest.categories = [ "System" ];
roles.default = {
perInstance.nixosModule =
{
lib,
...
}:
{
services.asterisk = {
enable = lib.mkDefault true;
confFiles = {
# Dial plan config
"extensions.conf" = ''
exten => 1001,1,Dial(PJSIP/user1,20)
exten => 1002,1,Dial(PJSIP/user2,20)
exten => 100,1,Answer()
same => n,Wait(1)
same => n,Playback(hello-world)
same => n,Hangup()
'';
"pjsip.conf" = ''
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0,[::]
[endpoint_internal](!)
type=endpoint
context=from-internal
disallow=all
allow=ulaw
[auth_userpass](!)
type=auth
auth_type=userpass
[aor_dynamic](!)
type=aor
max_contacts=1
[user1](endpoint_internal)
auth=user1
aors=user1
[user1](auth_userpass)
password=user1
username=user1
[user1](aor_dynamic)
[user2](endpoint_internal)
auth=user2
aors=user2
[user2](auth_userpass)
password=user2
username=user2
[user2](aor_dynamic)
'';
};
};
};
};
}

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")
'';
}