iac/nixos/hosts/rehearsal/services.nix
Sergei Poljanski 422eb3bc6e
nixos: bucket replica and XMPP certificate sync
s3-replicate is the same rclone sync with the same delete limit, run by
the rclone package instead of its image.

The certificate push keeps its shape: ops reads Traefik's acme.json and
sends each certificate over SSH with a key that may run one command on
services, from ops only. The key is now a sops secret with its public
half in the config, instead of being generated on the host, so a
rebuilt pair works without a manual step. Tried on the rehearsal pair
with a throwaway certificate; any other command is refused.

Assisted-by: Claude:fable-5-2
2026-11-16 23:27:47 +04:00

58 lines
2.1 KiB
Nix

# asxpio-services on a throwaway server; see ./ops.nix.
{ lib, ... }:
{
networking.hostName = "rehearsal-services";
sops.defaultSopsFile = ../../secrets/rehearsal-services.yaml;
asxpio.sshFrom = [ "*" ];
# Same script and schedule, into repositories on its own disk
asxpio.backup.repositories = lib.mkForce {
hel1 = "/var/backups/test-repo-hel1";
fsn1 = "/var/backups/test-repo-fsn1";
};
systemd.network.networks."10-public".address = lib.mkForce [ "2a01:4f9:c01d:6f9::1/64" ];
asxpio.publicIPv4 = "2.29.197.9";
asxpio.xmppCertSyncKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHXhvaO3Dhkw3QuMUHycoPU12Vx8bKWk2PCFoULvnTAf";
# A 4 GB server
services.minecraft-server.jvmOpts = lib.mkForce "-Xmx2G -Xms1G";
# A restored world brings its plugins and their credentials along.
# Those that talk to the outside (the Discord bot logs in with the
# production token and edits the real server's slash commands) are
# put aside before every start.
systemd.services.minecraft-server.preStart = lib.mkBefore ''
mkdir -p plugins/disabled-on-rehearsal
for p in DiscordSRV ServerBackup AutoUpdateGeyser; do
for f in plugins/$p*.jar; do
[ ! -e "$f" ] || mv "$f" plugins/disabled-on-rehearsal/
done
done
'';
# With production data restored these would act as production: a second
# asxp.io XMPP server and Telegram session. Start them by hand, and
# only with test data.
virtualisation.oci-containers.containers = lib.genAttrs [ "xmpp-ejabberd" "xmpp-apushd" "xmpp-tackygram" ] (_: {
autoStart = false;
});
# Dummy keys; and nothing here may write to the production buckets
systemd.timers.s3-replicate.enable = false;
# This runner would take real jobs of another project
systemd.services.forgejo-runner-interop.wantedBy = lib.mkForce [ ];
asxpio.wireguard.peers = [
{
name = "asxpio-ops";
publicKey = "Zuufncq9a9UZGvgRBjattzuoomJtWREjFeoB0POt620=";
endpoint = "62.238.40.174:60101"; # rehearsal-ops
allowedIPs = [
"10.20.0.0/24"
"fd69:69:69::/64"
];
}
];
}