{ pkgs, config, service_configs, lib, ... }: { systemd.services.torrent-audit = { description = "Audit qBittorrent for unmanaged and abandoned upgrade torrents"; after = [ "network-online.target" "sonarr.service" "radarr.service" "qbittorrent.service" ]; wants = [ "network-online.target" ]; serviceConfig = { Type = "oneshot"; ExecStart = "+${ pkgs.python3.withPackages ( ps: with ps; [ pyarr qbittorrent-api ] ) }/bin/python ${./torrent-audit.py}"; TimeoutSec = 300; }; environment = { QBITTORRENT_URL = "http://${config.vpnNamespaces.wg.namespaceAddress}:${builtins.toString service_configs.ports.private.torrent.port}"; RADARR_URL = "http://localhost:${builtins.toString service_configs.ports.private.radarr.port}"; RADARR_CONFIG = "${service_configs.radarr.dataDir}/config.xml"; SONARR_URL = "http://localhost:${builtins.toString service_configs.ports.private.sonarr.port}"; SONARR_CONFIG = "${service_configs.sonarr.dataDir}/config.xml"; CATEGORIES = lib.concatStringsSep "," (builtins.attrNames service_configs.torrent.categories); TAG_TORRENTS = "true"; }; }; }