2021-02-19 22:29:04 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.transmission;
|
|
|
|
|
|
|
|
domain = config.networking.domain;
|
|
|
|
webuiDomain = "transmission.${domain}";
|
|
|
|
|
|
|
|
transmissionRpcPort = 9091;
|
|
|
|
transmissionPeerPort = 30251;
|
|
|
|
|
|
|
|
downloadBase = "/media/torrents/";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.transmission = with lib; {
|
|
|
|
enable = mkEnableOption "Transmission torrent client";
|
|
|
|
|
|
|
|
username = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "alarsyo";
|
|
|
|
example = "username";
|
|
|
|
description = "Name of the transmission RPC user";
|
|
|
|
};
|
|
|
|
|
|
|
|
password = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "password";
|
|
|
|
description = "Password of the transmission RPC user";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.transmission = {
|
|
|
|
enable = true;
|
|
|
|
group = "media";
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
download-dir = "${downloadBase}/complete";
|
|
|
|
incomplete-dir = "${downloadBase}/incomplete";
|
|
|
|
|
|
|
|
peer-port = transmissionPeerPort;
|
|
|
|
|
|
|
|
rpc-enabled = true;
|
|
|
|
rpc-port = transmissionRpcPort;
|
|
|
|
rpc-authentication-required = true;
|
|
|
|
|
|
|
|
rpc-username = cfg.username;
|
|
|
|
rpc-password = cfg.password;
|
|
|
|
|
|
|
|
rpc-whitelist-enabled = true;
|
|
|
|
rpc-whitelist = "127.0.0.1";
|
|
|
|
};
|
2021-06-03 00:33:52 +02:00
|
|
|
|
|
|
|
# automatically allow transmission.settings.peer-port
|
|
|
|
openFirewall = true;
|
2021-02-19 22:29:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${webuiDomain}" = {
|
|
|
|
forceSSL = true;
|
2021-07-13 00:57:33 +02:00
|
|
|
useACMEHost = domain;
|
2021-02-19 22:29:04 +01:00
|
|
|
|
|
|
|
locations."/".proxyPass = "http://127.0.0.1:${toString transmissionRpcPort}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|