1{
2 config,
3 lib,
4 self,
5 ...
6}: let
7 cfg = config.myNixOS.profiles.arr;
8
9 netMap = config.mySnippets.tailnet.networkMap;
10in {
11 options.myNixOS.profiles.arr = {
12 enable = lib.mkEnableOption "*arr services";
13
14 dataDir = lib.mkOption {
15 type = lib.types.str;
16 default = "/var/lib";
17 description = "The directory where *arr stores its data files.";
18 };
19
20 autoProxy = lib.mkOption {
21 default = true;
22 example = false;
23 description = "auto proxy the *arrs";
24 type = lib.types.bool;
25 };
26 };
27
28 config = lib.mkMerge [
29 (lib.mkIf cfg.enable {
30 age.secrets.autobrr.file = "${self.inputs.secrets}/autobrr.age";
31
32 services = {
33 caddy.virtualHosts = lib.mkIf cfg.autoProxy {
34 "${netMap.autobrr.vHost}".extraConfig = ''
35 bind tailscale/autobrr
36 encode zstd gzip
37 reverse_proxy ${netMap.autobrr.hostName}:${toString netMap.autobrr.port}
38 '';
39
40 #"${netMap.bazarr.vHost}".extraConfig = ''
41 # bind tailscale/bazarr
42 # encode zstd gzip
43 # reverse_proxy ${netMap.bazarr.hostName}:${toString netMap.bazarr.port}
44 #'';
45
46 "${netMap.prowlarr.vHost}".extraConfig = ''
47 bind tailscale/prowlarr
48 encode zstd gzip
49 reverse_proxy ${netMap.prowlarr.hostName}:${toString netMap.prowlarr.port}
50 '';
51
52 "${netMap.radarr.vHost}".extraConfig = ''
53 bind tailscale/radarr
54 encode zstd gzip
55 reverse_proxy ${netMap.radarr.hostName}:${toString netMap.radarr.port}
56 '';
57
58 "${netMap.sonarr.vHost}".extraConfig = ''
59 bind tailscale/sonarr
60 encode zstd gzip
61 reverse_proxy ${netMap.sonarr.hostName}:${toString netMap.sonarr.port}
62 '';
63 };
64
65 autobrr = {
66 enable = true;
67 openFirewall = true; # Port: 7474
68 secretFile = config.age.secrets.autobrr.path;
69 settings = {
70 host = "0.0.0.0";
71 port = 7474;
72 };
73 };
74
75 #bazarr = {
76 # enable = true;
77 # dataDir = "${cfg.dataDir}/bazarr";
78 # openFirewall = true; # Port: 6767
79 #};
80
81 #lidarr = {
82 # enable = true;
83 # dataDir = "${cfg.dataDir}/lidarr/.config/Lidarr";
84 # openFirewall = true; # Port: 8686
85 #};
86
87 prowlarr = {
88 enable = true;
89 # dataDir = "${cfg.dataDir}/prowlarr";
90 openFirewall = true; # Port: 9696
91 };
92
93 radarr = {
94 enable = true;
95 dataDir = "${cfg.dataDir}/radarr/.config/Radarr/";
96 openFirewall = true; # Port: 7878
97 };
98
99 sonarr = {
100 enable = true;
101 dataDir = "${cfg.dataDir}/sonarr/.config/NzbDrone/";
102 openFirewall = true; # Port: 8989
103 };
104
105 #flaresolverr = {
106 # enable = true;
107 # openFirewall = true; # Port: 8191
108 #};
109 };
110
111 systemd = {
112 tmpfiles.rules = [
113 #"d ${config.services.lidarr.dataDir} 0755 lidarr lidarr"
114 "d ${config.services.radarr.dataDir} 0755 radarr radarr"
115 "d ${config.services.readarr.dataDir} 0755 readarr readarr"
116 "d ${config.services.sonarr.dataDir} 0755 sonarr sonarr"
117 "d ${config.myNixOS.profiles.arr.dataDir}/autobrr 0755 autobrr autobrr"
118 ];
119 };
120 })
121 ];
122}