1 { pkgs, lib, config, hostName, ... }:
3 inherit (config.services) transmission;
4 inherit (config.users) users;
5 inherit (config.security) gnupg;
9 users.groups.transmission.members = [
12 services.netns.namespaces.${netns}.nftables = ''
13 add rule inet filter input tcp dport ${toString transmission.settings.peer-port} counter accept comment "Transmission"
14 add rule inet filter input udp dport ${toString transmission.settings.peer-port} counter accept comment "Transmission"
15 add rule inet filter output meta skuid ${transmission.user} counter accept comment "Transmission"
17 #users.groups.keys.members = [ transmission.user ];
18 security.gnupg.secrets."transmission/settings.json" = {
19 user = transmission.user;
20 systemdConfig.before = [ "transmission.service" ];
21 systemdConfig.wantedBy = [ "transmission.service" ];
23 fileSystems."/var/lib/transmission" = {
24 device = "${hostName}/var/torrents";
27 systemd.services.transmission = {
29 "netns-${netns}.service"
33 "netns-${netns}.service"
37 serviceConfig.NetworkNamespacePath = "/var/run/netns/${netns}";
39 systemd.sockets.proxy-to-transmission = {
40 wantedBy = ["sockets.target"];
41 listenStreams = ["192.168.42.2:9091"];
42 socketConfig.FreeBind = true;
44 systemd.services.proxy-to-transmission = {
45 requires = ["transmission.service"];
46 after = ["transmission.service" "proxy-to-transmission.socket"];
47 unitConfig.JoinsNamespaceOf = ["transmission.service"];
49 ExecStart = "${pkgs.systemd}/lib/systemd/systemd-socket-proxyd 127.0.0.1:9091";
50 PrivateNetwork = true;
54 systemd.services.stop-transmission = {
55 serviceConfig.Type = "oneshot";
56 unitConfig.Conflicts = ["transmission.service"];
57 startAt = "06..19:0,15,30,45:00";
60 services.transmission = {
62 performanceNetParameters = true;
63 credentialsFile = gnupg.secrets."transmission/settings.json".path;
66 download-dir = "/var/lib/transmission/downloaded";
67 incomplete-dir = "/var/lib/transmission/.incoming";
68 incomplete-dir-enabled = true;
69 watch-dir = "/var/lib/transmission/.torrents";
70 watch-dir-enabled = true;
71 trash-original-torrent-files = false;
73 umask = 7; # 007 octal, in decimal!
74 download-queue-enabled = true;
75 download-queue-size = 5;
76 peer-id-ttl-hours = 6;
77 peer-limit-global = 1000;
78 peer-limit-per-torrent = 100;
81 peer-port-random-on-start = false;
86 port-forwarding-enabled = true;
87 scrape-paused-torrents-enabled = false;
88 peer-socket-tos = "lowcost";
89 queue-stalled-enabled = true;
90 queue-stalled-minutes = 30;
91 speed-limit-down-enabled = false;
93 speed-limit-up-enabled = true;
94 alt-speed-enabled = true;
95 alt-speed-time-enabled = true;
96 alt-speed-down = 1000;
98 alt-speed-time-day = 127; # all days. 65; # weekend only
99 alt-speed-time-begin = 360; # 06h00 local time
100 alt-speed-time-end = 1260; # 21h00 local time
102 ratio-limit-enabled = true;
105 rpc-bind-address = "127.0.0.1";
107 rpc-whitelist = "127.0.0.1,192.168.42.0/24";
108 rpc-whitelist-enabled = true;
109 rpc-host-whitelist = "localhost,${hostName}.wg";
110 rpc-host-whitelist-enabled = true;
111 rpc-authentication-required = true;