iac/nixos/hosts/asxpio-services/default.nix
Sergei Poljanski cbf14b4b99
nixos: monitoring as native services
Every host runs node_exporter, cAdvisor (now against Podman), Alloy and
the security-metrics script, on its private address. Each service
declares its own expected ports, users and privileged containers next
to its definition, so the security baseline follows the config instead
of a separate inventory list.

On ops: Prometheus, Loki, Grafana, the blackbox prober and the Postgres
exporter, with the same scrape jobs, probes, retention, dashboards and
33 alert rules. Two rules matched container-era names and now match the
native ones: Forgejo's log is unit forgejo.service, Grafana's route is
grafana@file.

Grafana keeps its default secret_key on production, because its
database was written with it; rotating it is a separate step.

Prometheus, Grafana and Alloy come from nixos-unstable: their data is
from newer versions than 26.05 ships.

LLMNR and mDNS are off: the baseline flagged them as public listeners.

Tried on the rehearsal pair: all 28 scrape targets up, logs from both
hosts in Loki, Grafana WireGuard-only, no unexpected port, user or
container on either host.

Assisted-by: Claude:opus-5-5
2026-11-17 04:48:56 +04:00

75 lines
2.3 KiB
Nix

# asxpio-services: CI runners, Minecraft, XMPP, Xray, SillyTavern.
# Services are added here as they move over from ../../ansible (see
# MIGRATION.md at the repo root); until then this is the base system only.
{ lib, ... }:
{
imports = [
./acme-forward.nix
./minecraft.nix
./replica.nix
./runner.nix
./sillytavern.nix
./xmpp.nix
./xmpp-cert-install.nix
./xray.nix
];
asxpio.publicIPv4 = lib.mkDefault "46.62.228.216";
networking.hostName = lib.mkDefault "asxpio-services";
networking.domain = "asxp.io";
asxpio.privateIPv4 = "10.10.0.20";
system.stateVersion = "26.05";
systemd.network.networks."10-public".address = [ "2a01:4f9:c013:8269::1/64" ];
# No swap, by choice
sops.defaultSopsFile = lib.mkDefault ../../secrets/asxpio-services.yaml;
# --- WireGuard spoke of asxpio-ops ---------------------------------------
asxpio.wireguard = {
interface = "asxpio-services";
address = [
"10.20.0.20/32"
"fd69:69:69::20/128"
];
listenPort = 52820;
peers = lib.mkDefault [
{
name = "asxpio-ops";
publicKey = "0gRrNiV4FjP6ipczZCRD3dsnK7k7rl6IyjG84fPaJB4=";
endpoint = "135.181.27.77:60101";
allowedIPs = [
"10.20.0.0/24"
"fd69:69:69::/64"
];
}
];
};
# --- Backup ---------------------------------------------------------------
# ejabberd's Mnesia through its own backup command, its SQLite through
# the online backup API. The Paper world is copied live (RCON is off, so
# there is no save-off); its autosave keeps that close enough.
asxpio.backup = {
hostName = "asxpio-services";
schedule = "*-*-* 04:15:00";
paths = [
"/etc/ssh" # the host key decrypts this host's secrets
"/opt"
"/var/lib/minecraft"
"/var/lib/SillyTavern"
"/var/lib/containers/storage/volumes/xmpp_database"
"/var/lib/containers/storage/volumes/xmpp_tackygram"
];
excludes = [
"/var/lib/minecraft/cache"
"/var/lib/minecraft/libraries"
"/var/lib/minecraft/versions"
];
hooks = [
"podman exec xmpp-ejabberd ejabberdctl backup /opt/ejabberd/database/nightly.backup"
''sqlite3 /var/lib/containers/storage/volumes/xmpp_database/_data/ejabberd.sqlite ".backup '$STAGE/ejabberd.sqlite'"''
];
};
}