2021-02-01 14:25:12 +01:00
|
|
|
# Small seedbox setup.
|
|
|
|
#
|
|
|
|
# Inspired by [1]
|
|
|
|
#
|
|
|
|
# [1]: https://github.com/delroth/infra.delroth.net/blob/master/roles/seedbox.nix
|
2023-09-28 18:02:22 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2021-02-01 14:25:12 +01:00
|
|
|
let
|
|
|
|
cfg = config.my.services.transmission;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.transmission = with lib; {
|
|
|
|
enable = mkEnableOption "Transmission torrent client";
|
2021-03-07 17:04:45 +01:00
|
|
|
|
2021-09-25 12:52:49 +02:00
|
|
|
credentialsFile = mkOption {
|
2021-02-01 14:25:12 +01:00
|
|
|
type = types.str;
|
2021-09-25 12:52:49 +02:00
|
|
|
example = "/var/lib/transmission/creds.json";
|
|
|
|
description = ''
|
|
|
|
Credential file as an json configuration file to be merged with
|
|
|
|
the main one.
|
|
|
|
'';
|
2021-02-01 14:25:12 +01:00
|
|
|
};
|
2021-03-07 17:04:45 +01:00
|
|
|
|
|
|
|
downloadBase = mkOption {
|
|
|
|
type = types.str;
|
2021-03-24 22:19:48 +01:00
|
|
|
default = "/data/downloads";
|
2021-03-07 17:04:45 +01:00
|
|
|
example = "/var/lib/transmission/download";
|
|
|
|
description = "Download base directory";
|
|
|
|
};
|
|
|
|
|
2021-08-24 23:05:10 +02:00
|
|
|
port = mkOption {
|
2021-03-07 17:04:45 +01:00
|
|
|
type = types.port;
|
|
|
|
default = 9091;
|
|
|
|
example = 8080;
|
|
|
|
description = "Internal port for webui";
|
|
|
|
};
|
|
|
|
|
|
|
|
peerPort = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 30251;
|
|
|
|
example = 32323;
|
|
|
|
description = "Peering port";
|
|
|
|
};
|
2021-02-01 14:25:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.transmission = {
|
|
|
|
enable = true;
|
2023-09-28 18:02:22 +02:00
|
|
|
package = pkgs.transmission_4;
|
2021-02-01 14:25:12 +01:00
|
|
|
group = "media";
|
|
|
|
|
2021-03-07 17:01:48 +01:00
|
|
|
downloadDirPermissions = "775";
|
|
|
|
|
2021-09-25 12:52:49 +02:00
|
|
|
inherit (cfg) credentialsFile;
|
|
|
|
|
2021-02-01 14:25:12 +01:00
|
|
|
settings = {
|
2021-03-07 17:04:45 +01:00
|
|
|
download-dir = "${cfg.downloadBase}/complete";
|
|
|
|
incomplete-dir = "${cfg.downloadBase}/incomplete";
|
2021-02-01 14:25:12 +01:00
|
|
|
|
2021-03-07 17:04:45 +01:00
|
|
|
peer-port = cfg.peerPort;
|
2021-02-01 14:25:12 +01:00
|
|
|
|
|
|
|
rpc-enabled = true;
|
2021-08-24 23:05:10 +02:00
|
|
|
rpc-port = cfg.port;
|
2021-02-01 14:25:12 +01:00
|
|
|
rpc-authentication-required = true;
|
|
|
|
|
|
|
|
# Proxied behind Nginx.
|
|
|
|
rpc-whitelist-enabled = true;
|
|
|
|
rpc-whitelist = "127.0.0.1";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-20 13:15:58 +01:00
|
|
|
# Transmission wants to eat *all* my RAM if left to its own devices
|
|
|
|
systemd.services.transmission = {
|
|
|
|
serviceConfig = {
|
|
|
|
MemoryMax = "33%";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-09-15 15:57:23 +02:00
|
|
|
# Set-up media group
|
|
|
|
users.groups.media = { };
|
|
|
|
|
2021-02-01 14:25:12 +01:00
|
|
|
# Default transmission webui, I prefer combustion but its development
|
|
|
|
# seems to have stalled
|
2023-12-25 19:25:08 +01:00
|
|
|
my.services.nginx.virtualHosts = {
|
|
|
|
transmission = {
|
2021-08-24 23:05:10 +02:00
|
|
|
inherit (cfg) port;
|
2023-12-25 19:25:08 +01:00
|
|
|
};
|
|
|
|
};
|
2021-02-01 14:25:12 +01:00
|
|
|
|
|
|
|
networking.firewall = {
|
2021-03-07 17:04:45 +01:00
|
|
|
allowedTCPPorts = [ cfg.peerPort ];
|
|
|
|
allowedUDPPorts = [ cfg.peerPort ];
|
2021-02-01 14:25:12 +01:00
|
|
|
};
|
2021-11-05 15:25:50 +01:00
|
|
|
|
|
|
|
my.system.persist.directories = [
|
|
|
|
config.services.transmission.home
|
|
|
|
];
|
2021-02-01 14:25:12 +01:00
|
|
|
};
|
|
|
|
}
|