106 lines
2.7 KiB
Nix
106 lines
2.7 KiB
Nix
{
|
|
lib,
|
|
config,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
port = 9091;
|
|
ports = [
|
|
port
|
|
51411
|
|
51412
|
|
51413
|
|
];
|
|
bencodepy = pkgs.python3Packages.buildPythonPackage {
|
|
pname = "bencodepy";
|
|
version = "0.9.5";
|
|
pyproject = true;
|
|
src = pkgs.fetchFromGitHub {
|
|
owner = "eweast";
|
|
repo = "bencodepy";
|
|
rev = "a9c145bd087c61dd8fb28a9dfad46d085c8b8290";
|
|
hash = "sha256-ISiMNTrA4J8NYUQSmdVFaro1RxkSqvXhz6LpoSn/fLQ=";
|
|
fetchSubmodules = true;
|
|
};
|
|
build-system = with pkgs.python3Packages; [ setuptools ];
|
|
};
|
|
qbit_manage_env = pkgs.python3.withPackages (
|
|
ps:
|
|
[
|
|
ps.croniter
|
|
ps.gitpython
|
|
ps.humanize
|
|
ps.pytimeparse2
|
|
ps.qbittorrent-api
|
|
ps.requests
|
|
ps.retrying
|
|
ps.ruamel-yaml
|
|
ps.schedule
|
|
]
|
|
++ [ bencodepy ]
|
|
);
|
|
in
|
|
{
|
|
options.my.servers = {
|
|
qbittorrent.enable = lib.mkEnableOption "enable";
|
|
unpackerr.enable = lib.mkEnableOption "enable";
|
|
};
|
|
config = lib.mkIf config.my.servers.qbittorrent.enable {
|
|
home-manager.users.jawz.xdg.configFile."unpackerr.conf" =
|
|
lib.mkIf config.my.servers.unpackerr.enable
|
|
{ source = ../../dotfiles/unpackerr.conf; };
|
|
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" ];
|
|
serviceConfig =
|
|
let
|
|
env = "/home/jawz/Development/Git/qbit_manage";
|
|
in
|
|
{
|
|
Restart = "on-failure";
|
|
RestartSec = 30;
|
|
ExecStart = "${qbit_manage_env}/bin/python ${env}/qbit_manage.py -r -c ${env}/config.yml";
|
|
};
|
|
};
|
|
unpackerr = lib.mkIf config.my.servers.unpackerr.enable {
|
|
enable = true;
|
|
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";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
networking.firewall = {
|
|
allowedTCPPorts = ports;
|
|
allowedUDPPorts = ports;
|
|
};
|
|
};
|
|
}
|