# XMPP certificates come from Traefik here (router xmpp-cert requests # xmpp.asxp.io + conference.; asxp.io is the site's own certificate) and # are pushed to ejabberd on asxpio-services on every renewal. { config, pkgs, ... }: let sync = pkgs.writers.writePython3 "xmpp-cert-sync" { flakeIgnore = [ "E501" ]; } (builtins.readFile ./xmpp-cert-sync.py); in { sops.secrets."xmpp_cert_sync/ssh_key" = { }; systemd.services.xmpp-cert-sync = { description = "Push the XMPP certificate from Traefik to ejabberd"; path = [ pkgs.openssh pkgs.openssl pkgs.coreutils ]; environment.XMPP_CERT_KEY = config.sops.secrets."xmpp_cert_sync/ssh_key".path; serviceConfig = { Type = "oneshot"; ExecStart = sync; StateDirectory = "xmpp-cert-sync"; }; }; systemd.paths.xmpp-cert-sync = { description = "Watch Traefik's acme.json for a renewed XMPP certificate"; wantedBy = [ "paths.target" ]; pathConfig.PathChanged = "/var/lib/traefik/acme.json"; }; systemd.timers.xmpp-cert-sync = { description = "Daily XMPP certificate check (fallback for the path unit)"; wantedBy = [ "timers.target" ]; timerConfig = { OnCalendar = "*-*-* 05:40:00"; Persistent = true; }; }; }