]> Git — Sourcephile - sourcephile-nix.git/blob - hosts/losurdo/transmission.nix
losurdo: improve X11 and Bluetooth support
[sourcephile-nix.git] / hosts / losurdo / transmission.nix
1 { pkgs, lib, config, hostName, ... }:
2 let
3 inherit (config.services) transmission;
4 inherit (config.users) users;
5 inherit (config.security) gnupg;
6 netns = "riseup";
7 in
8 {
9 users.groups.transmission.members = [
10 users."julm".name
11 ];
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"
16 '';
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" ];
22 };
23 fileSystems."/var/lib/transmission" = {
24 device = "${hostName}/var/torrents";
25 fsType = "zfs";
26 };
27 systemd.services.transmission = {
28 after = [
29 "netns-${netns}.service"
30 "zfs.target"
31 ];
32 requires = [
33 "netns-${netns}.service"
34 "zfs.target"
35 ];
36 serviceConfig.NetworkNamespacePath = "/var/run/netns/${netns}";
37 };
38 systemd.timers.transmission = {
39 timerConfig.OnCalendar = ["21:00:00"];
40 timerConfig.Persistent = true;
41 wantedBy = [ "timers.target" ];
42 };
43 systemd.services.stop-transmission = {
44 serviceConfig.Type = "oneshot";
45 unitConfig.Conflicts = ["transmission.service"];
46 script = "true";
47 };
48 systemd.timers.stop-transmission = {
49 timerConfig.OnCalendar = "06..20:*:00";
50 wantedBy = [ "timers.target" ];
51 };
52 services.transmission = {
53 enable = true;
54 performanceNetParameters = true;
55 credentialsFile = gnupg.secrets."transmission/settings.json".path;
56 settings = {
57 message-level = 2;
58 download-dir = "/home/julm/dl/torrents";
59 incomplete-dir = "/home/julm/dl/torrents/.incoming";
60 incomplete-dir-enabled = true;
61 trash-original-torrent-files = false;
62 preallocation = 0;
63 umask = 7; # 007 octal, in decimal!
64 download-queue-enabled = true;
65 download-queue-size = 5;
66 peer-id-ttl-hours = 6;
67 peer-limit-global = 1000;
68 peer-limit-per-torrent = 100;
69
70 peer-port = 6882;
71 peer-port-random-on-start = false;
72 encryption = 1;
73 dht-enabled = true;
74 lpd-enabled = false;
75 pex-enabled = true;
76 port-forwarding-enabled = true;
77 scrape-paused-torrents-enabled = false;
78 peer-socket-tos = "lowcost";
79 queue-stalled-enabled = true;
80 queue-stalled-minutes = 30;
81 speed-limit-down-enabled = false;
82 speed-limit-up = 50;
83 speed-limit-up-enabled = true;
84 alt-speed-enabled = true;
85 alt-speed-time-enabled = true;
86 alt-speed-down = 1000;
87 alt-speed-up = 0;
88 alt-speed-time-day = 127; # all days. 65; # weekend only
89 alt-speed-time-begin = 360; # 06h00 local time
90 alt-speed-time-end = 1260; # 21h00 local time
91 ratio-limit = 4;
92 ratio-limit-enabled = true;
93
94 rpc-enabled = true;
95 rpc-bind-address = "127.0.0.1";
96 rpc-port = 9091;
97 rpc-whitelist = "127.0.0.1";
98 rpc-whitelist-enabled = true;
99 #rpc-authentication-required = true;
100 };
101 };
102 }