iac/nixos/hosts/asxpio-services/xmpp-cert-install.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

32 lines
898 B
Nix

# Receiving end of xmpp-cert-sync on asxpio-ops (see its file there): the
# key below may run exactly one command, from ops only.
{
config,
lib,
pkgs,
...
}:
let
install = pkgs.writeShellApplication {
name = "xmpp-cert-install";
runtimeInputs = [
pkgs.coreutils
pkgs.openssl
pkgs.gnugrep
pkgs.util-linux
config.virtualisation.podman.package
];
text = builtins.readFile ./xmpp-cert-install.sh;
};
in
{
options.asxpio.xmppCertSyncKey = lib.mkOption {
type = lib.types.str;
default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAKd1FvOgmxeNCHUJzRQxNA3IBRz59A1VDdsnOwxhybl";
description = "Public half of xmpp_cert_sync/ssh_key in the ops secrets.";
};
config.users.users.root.openssh.authorizedKeys.keys = [
''restrict,from="10.10.0.10",command="${lib.getExe install}" ${config.asxpio.xmppCertSyncKey} xmpp-cert-sync''
];
}