{ lib, config, pkgs, proxyReverse, ... }: let port = 9091; ports = [ port 51413 ]; in { options.my.servers.qbittorrent.enable = lib.mkEnableOption "enable"; config = lib.mkIf config.my.servers.qbittorrent.enable { systemd = { packages = [ pkgs.qbittorrent-nox ]; services = { "qbittorrent-nox@jawz" = { enable = true; overrideStrategy = "asDropin"; wantedBy = [ "multi-user.target" ]; }; }; user = { services = { qbit_manage = { restartIfChanged = true; description = "Tidy up my torrents"; wantedBy = [ "default.target" ]; path = [ pkgs.python3 pkgs.pipenv ]; serviceConfig = { Restart = "on-failure"; RestartSec = 30; WorkingDirectory = "/home/jawz/Development/Git/qbit_manage"; ExecStart = "./venv/bin/python3 ./qbit_manage.py -r -c ./config.yml"; }; }; unpackerr = { enable = false; restartIfChanged = true; description = "Run unpackerr"; wantedBy = [ "default.target" ]; serviceConfig = { Restart = "on-failure"; RestartSec = 30; ExecStart = "${pkgs.unpackerr}/bin/unpackerr -c /home/jawz/.config/unpackerr.conf"; }; }; }; timers.qbit_manage = { enable = true; description = "Tidy up my torrents"; wantedBy = [ "timers.target" ]; timerConfig = { OnCalendar = "*:0/10"; }; }; }; }; services.nginx = { enable = true; virtualHosts."xfwmrle6h6skqujbeizw.${config.my.domain}" = proxyReverse port // { }; }; networking.firewall = { allowedTCPPorts = ports; allowedUDPPorts = ports; }; }; }