1 { pkgs, lib, config, inputs, hostName, ... }:
3 inherit (config.services) transmission;
4 inherit (config.users) users;
8 users.groups.transmission.members = [
12 networking.nftables.ruleset = lib.mkIf config.services.nebula.networks.sourcephile.enable ''
14 chain input-neb-sourcephile {
15 tcp dport ${toString transmission.settings.rpc-port} \
16 counter accept comment "transmission: rpc"
20 services.netns.namespaces.${netns}.nftables = ''
23 meta l4proto { udp, tcp } \
24 th dport ${toString transmission.settings.peer-port} \
25 counter accept comment "transmission"
28 skuid ${transmission.user} counter accept comment "transmission"
32 fileSystems."/var/lib/transmission" = {
33 device = "${hostName}/var/torrents";
36 systemd.services.transmission = {
38 "netns-${netns}.service"
42 "netns-${netns}.service"
46 unitConfig.JoinsNamespaceOf = [ "netns-${netns}.service" ];
47 serviceConfig.BindReadOnlyPaths = [ "/etc/netns/${netns}/resolv.conf:/etc/resolv.conf" ];
48 serviceConfig.PrivateNetwork = true;
49 #serviceConfig.NetworkNamespacePath = "/var/run/netns/${netns}";
51 systemd.sockets.proxy-to-transmission = {
52 wantedBy = [ "sockets.target" ];
53 listenStreams = [ "10.0.0.2:9091" ];
54 socketConfig.FreeBind = true;
56 systemd.services.proxy-to-transmission = {
57 requires = [ "transmission.service" ];
58 after = [ "transmission.service" "proxy-to-transmission.socket" ];
59 unitConfig.JoinsNamespaceOf = [ "netns-${netns}.service" ];
61 ExecStart = "${pkgs.systemd}/lib/systemd/systemd-socket-proxyd 127.0.0.1:9091";
62 PrivateNetwork = true;
66 systemd.services.stop-transmission = {
67 serviceConfig.Type = "oneshot";
68 unitConfig.Conflicts = [ "transmission.service" ];
69 startAt = "06..19:0,15,30,45:00";
72 systemd.services.transmission.serviceConfig.LoadCredentialEncrypted = [
73 "settings.json:${transmission/settings.json.cred}"
75 services.transmission = {
77 performanceNetParameters = true;
78 # FIXME: need latest systemd to exist in ExecStartPre=
79 credentialsFile = "/run/credentials/transmission.service/settings.json";
82 download-dir = "/var/lib/transmission/downloaded";
83 incomplete-dir = "/var/lib/transmission/.incoming";
84 incomplete-dir-enabled = true;
85 watch-dir = "/var/lib/transmission/.torrents";
86 watch-dir-enabled = true;
87 trash-original-torrent-files = false;
89 umask = 7; # 007 octal, in decimal!
90 download-queue-enabled = true;
91 download-queue-size = 5;
92 peer-id-ttl-hours = 6;
93 peer-limit-global = 1000;
94 peer-limit-per-torrent = 100;
97 peer-port-random-on-start = false;
102 port-forwarding-enabled = true;
103 scrape-paused-torrents-enabled = false;
104 peer-socket-tos = "lowcost";
105 queue-stalled-enabled = true;
106 queue-stalled-minutes = 30;
107 speed-limit-down-enabled = false;
109 speed-limit-up-enabled = true;
110 alt-speed-enabled = true;
111 alt-speed-time-enabled = true;
112 alt-speed-down = 1000;
114 alt-speed-time-day = 127; # all days. 65; # weekend only
115 alt-speed-time-begin = 360; # 06h00 local time
116 alt-speed-time-end = 1260; # 21h00 local time
118 ratio-limit-enabled = true;
121 rpc-bind-address = "127.0.0.1";
123 rpc-whitelist = "127.0.0.1,${hostName}.sp,oignon.sp";
124 rpc-whitelist-enabled = true;
125 rpc-host-whitelist = "localhost,${hostName}.sp";
126 rpc-host-whitelist-enabled = true;
127 rpc-authentication-required = true;