Start of the move from Ansible to NixOS. Services run as native NixOS services where nixpkgs has a module and as Podman containers otherwise; there is no Docker. Shared: users with their Debian UIDs, SSH with the Ansible role's crypto settings, nftables firewall, WireGuard (ops is the hub), sops-nix secrets per host, the restic backup script with its schedule and retention, mail on unit failure. asxpio-services: Xray, SillyTavern, Minecraft (Paper) and the ACME forwarder natively; XMPP stays in containers because the server is a custom build. asxpio-ops: Postgres, Garage and Forgejo natively. Roles, buckets, keys and grants move here from the storage repo's init scripts. Services that own data wait for /var/lib/.data-in-place, so an install never creates empty state where a restore is about to land. migration/*-data.sh move the Debian-era data into the new layout. hosts/rehearsal turns the two hosts into a test pair with its own keys and dummy secrets. Everything here ran there, Postgres, Garage, Forgejo, Minecraft and SillyTavern on a restored copy of production data. Three differences from the containers showed up and are handled: Garage rejects a 0440 credential file, Geyser needs libcrypto and netlink, SillyTavern ignores the module's listen flags. Production is untouched: both servers still run Debian under Ansible. Assisted-by: Claude:fable-5-2
100 lines
3.3 KiB
Nix
100 lines
3.3 KiB
Nix
# XMPP for asxp.io: another.im's ejabberd build, its push server and the
|
|
# Telegram gateway. A custom image, so containers; the two helpers share
|
|
# ejabberd's network namespace and reach its component port on 127.0.0.1.
|
|
#
|
|
# /opt/xmpp/state (secrets.env, certs/, apushd/, tackygram/) is host data:
|
|
# generated once, backed up, not in this repo. Certificates arrive there
|
|
# from asxpio-ops (xmpp-cert-sync).
|
|
{ config, lib, ... }:
|
|
let
|
|
# renovate: datasource=docker depName=dev.another.im/another-im/anotherim-server
|
|
ejabberd = "dev.another.im/another-im/anotherim-server:2026.11.07";
|
|
# renovate: datasource=docker depName=dev.another.im/another-im/apushd
|
|
apushd = "dev.another.im/another-im/apushd:0.2";
|
|
# renovate: datasource=docker depName=dev.another.im/another-im/tackygram
|
|
tackygram = "dev.another.im/another-im/tackygram:0.4.3";
|
|
|
|
callPorts = "50000-50099";
|
|
state = "/opt/xmpp/state";
|
|
helper = {
|
|
dependsOn = [ "xmpp-ejabberd" ];
|
|
extraOptions = [ "--network=container:xmpp-ejabberd" ];
|
|
};
|
|
in
|
|
{
|
|
options.asxpio.publicIPv4 = lib.mkOption { type = lib.types.str; };
|
|
|
|
config = {
|
|
virtualisation.oci-containers.containers = {
|
|
xmpp-ejabberd = {
|
|
image = ejabberd;
|
|
environment = {
|
|
EJABBERD_MACRO_XMPP_DOMAIN = "asxp.io";
|
|
EJABBERD_MACRO_TURN_IP = config.asxpio.publicIPv4;
|
|
EJABBERD_MACRO_POW_DIFFICULTY = "6";
|
|
EJABBERD_MACRO_REGISTRATION_TIMEOUT = "600";
|
|
EJABBERD_MACRO_UPLOAD_URL = "https://hel1.your-objectstorage.com/asxpio-xmpp-public/";
|
|
EJABBERD_MACRO_ACME_URL = "https://acme-v02.api.letsencrypt.org/directory";
|
|
};
|
|
environmentFiles = [ "${state}/secrets.env" ];
|
|
ports = [
|
|
"5222:5222" # clients, STARTTLS
|
|
"5223:5223" # clients, direct TLS
|
|
"5269:5269" # other servers
|
|
"5443:5443" # WebSocket, host-meta
|
|
"8448:8448" # Matrix federation
|
|
"3478:3478/udp" # STUN and TURN
|
|
"3478:3478/tcp"
|
|
"49160-49199:49160-49199/udp" # TURN relay
|
|
"7777:7777" # SOCKS5 bytestreams proxy
|
|
"${callPorts}:${callPorts}/udp" # gateway calls
|
|
];
|
|
volumes = [
|
|
"xmpp_database:/opt/ejabberd/database"
|
|
"xmpp_logs:/opt/ejabberd/logs"
|
|
"${state}/certs:/opt/ejabberd/conf/certs:ro"
|
|
];
|
|
};
|
|
|
|
xmpp-apushd = helper // {
|
|
image = apushd;
|
|
volumes = [ "${state}/apushd:/etc/apushd:ro" ];
|
|
};
|
|
|
|
xmpp-tackygram = helper // {
|
|
image = tackygram;
|
|
environment = {
|
|
CREDENTIALS_DIRECTORY = "/run/credentials";
|
|
TACKYGRAM_CALL_IP = config.asxpio.publicIPv4;
|
|
TACKYGRAM_CALL_PORTS = callPorts;
|
|
};
|
|
environmentFiles = [ "${state}/tackygram/env" ];
|
|
volumes = [
|
|
"xmpp_tackygram:/var/lib/tackygram"
|
|
"${state}/tackygram/key:/run/credentials/gateway-key:ro"
|
|
];
|
|
};
|
|
};
|
|
|
|
asxpio.waitForData = [
|
|
"podman-xmpp-ejabberd"
|
|
"podman-xmpp-apushd"
|
|
"podman-xmpp-tackygram"
|
|
];
|
|
|
|
networking.firewall.allowedTCPPorts = [
|
|
5222
|
|
5223
|
|
5269
|
|
5443
|
|
8448
|
|
3478
|
|
7777
|
|
];
|
|
networking.firewall.allowedUDPPorts = [ 3478 ];
|
|
networking.firewall.allowedUDPPortRanges = [
|
|
{ from = 49160; to = 49199; }
|
|
{ from = 50000; to = 50099; }
|
|
];
|
|
};
|
|
}
|