iac/nixos/hosts/asxpio-services/minecraft.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

38 lines
1.1 KiB
Nix

# Paper. The world, plugins and server.properties are data in
# /var/lib/minecraft and not managed here; Geyser (a plugin) adds the
# Bedrock port.
{ lib, pkgs, ... }:
{
services.minecraft-server = {
enable = true;
eula = true;
package = pkgs.papermc;
jvmOpts = "-Xmx4G -Xms2G";
};
asxpio.waitForData = [ "minecraft-server" ];
systemd.services.minecraft-server = {
# Stopping saves the world first
serviceConfig.TimeoutStopSec = 120;
# Geyser lists the network interfaces (netlink) for Bedrock's
# signalling; the module allows IP sockets only
serviceConfig.RestrictAddressFamilies = lib.mkForce [
"AF_INET"
"AF_INET6"
"AF_UNIX"
"AF_NETLINK"
];
# Geyser unpacks native libraries that expect a usual Linux around
# them (libcrypto, libstdc++)
environment.LD_LIBRARY_PATH = lib.makeLibraryPath [
pkgs.openssl
pkgs.stdenv.cc.cc.lib
];
};
networking.firewall.allowedTCPPorts = [ 25565 ];
asxpio.security.ports = [
"tcp/25565/java"
"tcp/19132/java" # Geyser's signalling
"udp/19132/java" # Bedrock
];
networking.firewall.allowedUDPPorts = [ 19132 ];
}