2024-04-22 23:59:18 +02:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
secrets,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
# Deluge BitTorrent Client is a free and open-source, cross-platform
|
|
|
|
# BitTorrent client written in Python.
|
|
|
|
# https://www.deluge-torrent.org/
|
|
|
|
services.deluge = {
|
|
|
|
enable = true;
|
2024-04-24 00:05:25 +02:00
|
|
|
# Use the 'torrent' group to share files amongst downloaders, indexers etc.
|
|
|
|
group = "torrent";
|
2024-04-22 23:59:18 +02:00
|
|
|
web.enable = true;
|
2024-04-24 00:05:25 +02:00
|
|
|
# Config defaults:
|
2024-04-22 23:59:18 +02:00
|
|
|
# https://git.deluge-torrent.org/deluge/tree/deluge/core/preferencesmanager.py#n41
|
|
|
|
declarative = true;
|
|
|
|
config = {
|
2024-04-24 00:05:25 +02:00
|
|
|
download_location = "/srv/torrents/downloads/";
|
|
|
|
# use the dedicated network interface and port
|
2024-05-10 18:50:22 +02:00
|
|
|
listen_interface = secrets.hosts.sigma.sigma-p2p-ip-address;
|
2024-04-22 23:59:18 +02:00
|
|
|
outgoing_interface = "wg-sigma-p2p";
|
|
|
|
random_port = false;
|
|
|
|
listen_ports = [60881];
|
|
|
|
# no limits
|
|
|
|
max_connections_global = -1;
|
|
|
|
max_upload_slots_global = -1;
|
|
|
|
max_half_open_connections = -1;
|
|
|
|
max_connections_per_second = -1;
|
|
|
|
max_active_seeding = -1;
|
|
|
|
max_active_downloading = -1;
|
|
|
|
max_active_limit = -1;
|
|
|
|
# caching
|
|
|
|
cache_size = 65536; # 65536 x 16KiB = 1GiB
|
2024-04-24 00:05:25 +02:00
|
|
|
# enable label plugin, primarily for sonarr
|
2024-04-22 23:59:18 +02:00
|
|
|
enabled_plugins = ["Label"];
|
|
|
|
};
|
|
|
|
# authfile is required with declarative=true; allow access from webui
|
|
|
|
authFile = pkgs.writeTextFile {
|
|
|
|
name = "deluge-auth";
|
|
|
|
text = ''
|
|
|
|
localclient::10
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-26 01:25:50 +02:00
|
|
|
# Only allow deluged internet access through wg-sigma-p2p. Note that this
|
|
|
|
# does not tell it to use the correct routing table. For proper internet
|
|
|
|
# access, the correct routing table is also configured by
|
|
|
|
# routingPolicyRuleConfig in networking.nix.
|
2024-04-22 23:59:18 +02:00
|
|
|
systemd.services.deluged = {
|
|
|
|
serviceConfig = {
|
|
|
|
RestrictNetworkInterfaces = "lo wg-sigma-p2p";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-05-01 22:12:37 +02:00
|
|
|
# Add caspervk user to the 'torrent' group to allow viewing downloads
|
|
|
|
users.groups.torrent.members = ["caspervk"];
|
|
|
|
|
2024-04-22 23:59:18 +02:00
|
|
|
environment.persistence."/nix/persist" = {
|
|
|
|
directories = [
|
2024-04-24 00:05:25 +02:00
|
|
|
# Deluge data directory. This is *NOT* where the downloads are saved
|
2024-04-22 23:59:18 +02:00
|
|
|
{
|
|
|
|
directory = "/var/lib/deluge";
|
|
|
|
user = "deluge";
|
2024-04-24 00:05:25 +02:00
|
|
|
group = "torrent";
|
|
|
|
mode = "0770";
|
|
|
|
}
|
|
|
|
# Since Sonarr insists on using hardlinks to manage media files, its
|
|
|
|
# media library must be on the same volume as Deluge stores its
|
|
|
|
# downloads. Therefore, Deluge will save to /srv/torrents/downloads/ and
|
|
|
|
# Sonarr will hardlink in /srv/torrents/tv/. Jellyfin reads from
|
|
|
|
# /srv/torrents/downloads/movies/ and /srv/torrents/tv/.
|
|
|
|
{
|
|
|
|
directory = "/srv/torrents";
|
2024-05-01 22:12:37 +02:00
|
|
|
user = "deluge";
|
2024-04-24 00:05:25 +02:00
|
|
|
group = "torrent";
|
2024-04-22 23:59:18 +02:00
|
|
|
mode = "0770";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|