nixos: drop the rehearsal pair and other migration leftovers
All checks were successful
nixos / nixos (push) Successful in 1m3s

The test pair served the move to NixOS, which is done. Its overlays,
dummy secrets and sops recipients go; the rules for testing on a copy
of production stay in nixos/README.md, and git log finds the overlay
if it is needed again. Options that existed only for it (alert address,
Loki bucket, extra cert-push keys) are inlined, and comments still
pointing at Ansible or MIGRATION.md are corrected.

The tofu README now spells out the state bucket bootstrap: the bucket
is a resource in the state it holds, so a new project needs one local
apply first. The bucket gets prevent_destroy for the same reason.

Assisted-by: Claude:opus-5-5
This commit is contained in:
Sergei Poljanski 2026-11-17 11:11:33 +04:00
commit 2635b887c7
Signed by: asxpi
GPG key ID: 4F8851660FA4121B
10 changed files with 56 additions and 380 deletions

View file

@ -1,6 +1,4 @@
# asxpio-ops: Traefik, Forgejo, storage, the app stacks.
# 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 = [
@ -9,13 +7,12 @@
./forgejo.nix
./garage.nix
./monitoring
./options.nix
./postgres.nix
./traefik.nix
./xmpp-cert-sync.nix
];
networking.hostName = lib.mkDefault "asxpio-ops";
networking.hostName = "asxpio-ops";
networking.domain = "asxp.io";
asxpio.privateIPv4 = "10.10.0.10";
system.stateVersion = "26.05";

View file

@ -1,4 +1,3 @@
# Managed by Ansible (role monitoring).
apiVersion: 1
groups:
- orgId: 1

View file

@ -315,7 +315,7 @@ in
storage_config.aws = {
endpoint = "hel1.your-objectstorage.com";
region = "hel1";
bucketnames = config.asxpio.lokiBucket;
bucketnames = "asxpio-loki-main";
access_key_id = "\${S3_ACCESS_KEY}";
secret_access_key = "\${S3_SECRET_KEY}";
};
@ -426,7 +426,7 @@ in
uid = "email-me";
type = "email";
settings = {
addresses = config.asxpio.alertEmail;
addresses = "me@asxp.io";
singleEmail = true;
};
}

View file

@ -1,15 +0,0 @@
# Values the rehearsal host overrides.
{ lib, ... }:
{
options.asxpio = {
alertEmail = lib.mkOption {
type = lib.types.str;
default = "me@asxp.io";
description = "Where Grafana sends alerts.";
};
lokiBucket = lib.mkOption {
type = lib.types.str;
default = "asxpio-loki-main";
};
};
}

View file

@ -1,6 +1,4 @@
# 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 = [
@ -16,7 +14,7 @@
asxpio.publicIPv4 = lib.mkDefault "46.62.228.216";
networking.hostName = lib.mkDefault "asxpio-services";
networking.hostName = "asxpio-services";
networking.domain = "asxp.io";
asxpio.privateIPv4 = "10.10.0.20";
system.stateVersion = "26.05";

View file

@ -26,13 +26,7 @@ in
description = "Public half of xmpp_cert_sync/ssh_key in the ops secrets.";
};
options.asxpio.xmppCertSyncKeysExtra = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "Further keys allowed to push certificates (e.g. during a migration).";
};
config.users.users.root.openssh.authorizedKeys.keys = map (
key: ''restrict,from="10.10.0.10",command="${lib.getExe install}" ${key} xmpp-cert-sync''
) ([ config.asxpio.xmppCertSyncKey ] ++ config.asxpio.xmppCertSyncKeysExtra);
) [ config.asxpio.xmppCertSyncKey ];
}

View file

@ -23,7 +23,7 @@ key_pub=$(openssl pkey -in "$tmp" -pubout | sha256sum)
chmod 0644 "$tmp"
mv "$tmp" "$dir/$name.pem"
trap - EXIT
# Not running during a restore or on a rehearsal host: ejabberd reads the
# Not running during a restore: ejabberd reads the
# file at its next start
if podman container exists xmpp-ejabberd; then
podman exec xmpp-ejabberd ejabberdctl reload_config

View file

@ -1,74 +0,0 @@
# asxpio-ops on a throwaway server: the same system with its own keys,
# its own addresses and SSH open to the world. Pairs with ./services.nix
# on a private network with the production addresses (10.10.0.10/.20).
{ lib, ... }:
{
networking.hostName = "rehearsal-ops";
sops.defaultSopsFile = ../../secrets/rehearsal-ops.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:c015:f949::1/64" ];
# A restored copy of production must not mail anyone, sync mirrors or
# call webhooks
services.forgejo.settings = {
mailer.ENABLED = false;
service.ENABLE_NOTIFY_MAIL = lib.mkForce false;
mirror.ENABLED = false;
webhook.ALLOWED_HOST_LIST = "loopback";
"cron.update_mirrors".ENABLED = false;
};
# The names point at production, so no challenge can succeed here:
# ask the staging CA, and expect Traefik's self-signed certificate
asxpio.letsencryptCA = "https://acme-staging-v02.api.letsencrypt.org/directory";
# No alert mail from a test pair
asxpio.alertEmail = "nobody@example.invalid";
services.grafana.settings.smtp.enabled = lib.mkForce false;
systemd.timers.crawler-alert.enable = false;
# No services host behind 10.10.0.20 on the test network
systemd.paths.xmpp-cert-sync.enable = false;
systemd.timers.xmpp-cert-sync.enable = false;
systemd.timers.crawler-weekly.enable = false;
services.loki.configuration = {
# No Object Storage keys here: everything on local disk
schema_config.configs = lib.mkForce [
{
from = "2026-11-01";
store = "tsdb";
object_store = "filesystem";
schema = "v13";
index = {
prefix = "index_";
period = "24h";
};
}
];
compactor.delete_request_store = lib.mkForce "filesystem";
};
asxpio.wireguard.peers = [
{
name = "asxpio-services";
publicKey = "DwCNEfzgV1fU2ZPwEwkxun/s8vMZYrzdp74ZDrrSTD4=";
allowedIPs = [
"10.20.0.20/32"
"fd69:69:69::20/128"
];
}
{
name = "laptop";
publicKey = "iTY+NChSd8pcm/vke8s8EqsxjwEJpBEc07PfEg1Q0zQ=";
allowedIPs = [
"10.20.0.2/32"
"fd69:69:69::2/128"
];
}
];
}

View file

@ -1,33 +0,0 @@
#!/usr/bin/env bash
# REHEARSAL HOSTS ONLY. Run after restoring production's Forgejo data and
# before any runner is started against it.
#
# A restored database still has production's queued jobs, its schedules
# and its Actions secrets (deploy keys, registry tokens). A runner would
# pick the jobs up and deploy to production from the test server. This
# cancels what is queued, removes the schedules and deletes every secret.
set -euo pipefail
case "$(hostname)" in
rehearsal-*) ;;
*) echo "refusing: $(hostname) is not a rehearsal host" >&2; exit 1 ;;
esac
db=/var/lib/forgejo/data/forgejo.db
systemctl stop forgejo.service
sqlite3 "$db" <<'SQL'
BEGIN;
DELETE FROM secret;
-- 3 = cancelled; 5 waiting, 6 running, 7 blocked
UPDATE action_run_job SET status = 3 WHERE status IN (5, 6, 7);
UPDATE action_run SET status = 3 WHERE status IN (5, 6, 7);
UPDATE action_task SET status = 3 WHERE status IN (5, 6, 7);
DELETE FROM action_schedule_spec;
DELETE FROM action_schedule;
DELETE FROM action_runner;
DELETE FROM webhook;
DELETE FROM push_mirror;
COMMIT;
SQL
systemctl start forgejo.service
echo "sanitized: no secrets, no queued jobs, no schedules, no runners, no webhooks"

View file

@ -1,61 +0,0 @@
# 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.xmppCertSyncKeysExtra = [ ];
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 [ ];
# Production's runner UUID: a rehearsal needs a runner of its own
systemd.services.forgejo-runner-asxpio.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"
];
}
];
}