217 lines
6 KiB
Nix
217 lines
6 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.my.services.media-mgr;
|
|
in
|
|
{
|
|
options.my.services.media-mgr = {
|
|
|
|
programs = {
|
|
enable = lib.mkEnableOption "Enable the download manager stack";
|
|
commonSecretsFile = lib.mkOption {
|
|
default = "";
|
|
type = lib.types.path;
|
|
description = ''
|
|
Path to the file containing secrets in common between Arr
|
|
'';
|
|
};
|
|
};
|
|
|
|
exportMetrics = {
|
|
enable = lib.mkEnableOption "Enable monitoring for the download manager stack";
|
|
apiKeyFile = lib.mkOption {
|
|
default = "";
|
|
type = lib.types.path;
|
|
description = ''
|
|
Path to the file containing the Arr secrets API key (look also commonSecretsFile)
|
|
'';
|
|
};
|
|
};
|
|
|
|
proxy = {
|
|
enable = lib.mkEnableOption "Set the proxy entry for this service";
|
|
|
|
domain = lib.mkOption {
|
|
default = "example.com";
|
|
type = lib.types.str;
|
|
description = ''
|
|
The domain where Caddy is reachable
|
|
'';
|
|
};
|
|
|
|
host = lib.mkOption {
|
|
default = "localhost";
|
|
type = lib.types.str;
|
|
description = ''
|
|
host name where the download manager stack is running
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = lib.mkMerge [
|
|
|
|
# Services definition
|
|
(lib.mkIf cfg.programs.enable {
|
|
|
|
services = {
|
|
|
|
# Indexer
|
|
prowlarr = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
environmentFiles = [ cfg.programs.commonSecretsFile ];
|
|
};
|
|
|
|
# Movies
|
|
radarr = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
environmentFiles = [ cfg.programs.commonSecretsFile ];
|
|
};
|
|
|
|
# TV Shows
|
|
sonarr = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
environmentFiles = [ cfg.programs.commonSecretsFile ];
|
|
};
|
|
|
|
# Music
|
|
lidarr = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
environmentFiles = [ cfg.programs.commonSecretsFile ];
|
|
};
|
|
|
|
# E-books
|
|
readarr = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
environmentFiles = [ cfg.programs.commonSecretsFile ];
|
|
};
|
|
|
|
# Subtitles
|
|
bazarr = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
};
|
|
|
|
# Request management and media discovery tool for the Plex ecosystem
|
|
jellyseerr = {
|
|
enable = true;
|
|
openFirewall = true;
|
|
};
|
|
|
|
# Proxy server to bypass Cloudflare protection
|
|
flaresolverr.enable = true;
|
|
|
|
};
|
|
})
|
|
|
|
# Caddy for reverse proxy
|
|
(lib.mkIf cfg.proxy.enable {
|
|
services.caddy = with cfg.proxy; {
|
|
virtualHosts."prowlarr.ts.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.prowlarr.settings.server.port}
|
|
import cloudflare_${domain}
|
|
'';
|
|
virtualHosts."radarr.ts.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.radarr.settings.server.port}
|
|
import cloudflare_${domain}
|
|
'';
|
|
virtualHosts."sonarr.ts.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.sonarr.settings.server.port}
|
|
import cloudflare_${domain}
|
|
'';
|
|
virtualHosts."lidarr.ts.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.lidarr.settings.server.port}
|
|
import cloudflare_${domain}
|
|
'';
|
|
virtualHosts."readarr.ts.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.readarr.settings.server.port}
|
|
import cloudflare_${domain}
|
|
'';
|
|
virtualHosts."bazarr.ts.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.bazarr.listenPort}
|
|
import cloudflare_${domain}
|
|
'';
|
|
virtualHosts."jellyseerr.ts.${domain}".extraConfig = ''
|
|
reverse_proxy http://${host}:${toString config.services.jellyseerr.port}
|
|
import cloudflare_${domain}
|
|
'';
|
|
};
|
|
})
|
|
|
|
# Prometheus exporters
|
|
(lib.mkIf cfg.exportMetrics.enable {
|
|
|
|
users.groups.exportarr = { };
|
|
users.users.exportarr = {
|
|
group = "exportarr";
|
|
isSystemUser = true;
|
|
};
|
|
|
|
services.prometheus.exporters = with cfg.proxy; {
|
|
exportarr-prowlarr = {
|
|
enable = true;
|
|
url = "http://${host}:${toString config.services.prowlarr.settings.server.port}";
|
|
port = 9701;
|
|
user = "exportarr";
|
|
group = "exportarr";
|
|
apiKeyFile = cfg.exportMetrics.apiKeyFile;
|
|
};
|
|
exportarr-radarr = {
|
|
enable = true;
|
|
url = "http://${host}:${toString config.services.radarr.settings.server.port}";
|
|
port = 9702;
|
|
user = "exportarr";
|
|
group = "exportarr";
|
|
apiKeyFile = cfg.exportMetrics.apiKeyFile;
|
|
};
|
|
exportarr-sonarr = {
|
|
enable = true;
|
|
url = "http://${host}:${toString config.services.sonarr.settings.server.port}";
|
|
port = 9703;
|
|
user = "exportarr";
|
|
group = "exportarr";
|
|
apiKeyFile = cfg.exportMetrics.apiKeyFile;
|
|
};
|
|
exportarr-lidarr = {
|
|
enable = true;
|
|
url = "http://${host}:${toString config.services.lidarr.settings.server.port}";
|
|
port = 9704;
|
|
user = "exportarr";
|
|
group = "exportarr";
|
|
apiKeyFile = cfg.exportMetrics.apiKeyFile;
|
|
};
|
|
exportarr-readarr = {
|
|
enable = true;
|
|
url = "http://${host}:${toString config.services.readarr.settings.server.port}";
|
|
port = 9705;
|
|
user = "exportarr";
|
|
group = "exportarr";
|
|
apiKeyFile = cfg.exportMetrics.apiKeyFile;
|
|
};
|
|
exportarr-bazarr = {
|
|
enable = true;
|
|
url = "http://${host}:${toString config.services.bazarr.listenPort}";
|
|
port = 9706;
|
|
user = "exportarr";
|
|
group = "exportarr";
|
|
apiKeyFile = cfg.exportMetrics.apiKeyFile;
|
|
};
|
|
};
|
|
})
|
|
|
|
];
|
|
}
|