2023-09-24 22:31:21 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.shb.arr;
|
|
|
|
|
2024-01-12 08:22:46 +01:00
|
|
|
contracts = pkgs.callPackage ../contracts {};
|
2024-02-10 05:56:26 +01:00
|
|
|
shblib = pkgs.callPackage ../../lib {};
|
2024-01-12 08:22:46 +01:00
|
|
|
|
2023-09-24 22:31:21 +02:00
|
|
|
apps = {
|
|
|
|
radarr = {
|
2024-05-23 23:28:08 +02:00
|
|
|
settingsFormat = shblib.formatXML { enclosingRoot = "Config"; };
|
2023-11-15 21:44:47 +01:00
|
|
|
moreOptions = {
|
|
|
|
settings = lib.mkOption {
|
2023-12-04 09:33:16 +01:00
|
|
|
description = "Specific options for radarr.";
|
2023-11-15 21:44:47 +01:00
|
|
|
default = {};
|
|
|
|
type = lib.types.submodule {
|
|
|
|
freeformType = apps.radarr.settingsFormat.type;
|
|
|
|
options = {
|
2024-05-23 23:28:08 +02:00
|
|
|
ApiKey = lib.mkOption {
|
2024-03-13 06:40:32 +01:00
|
|
|
type = shblib.secretFileType;
|
2023-12-04 09:33:16 +01:00
|
|
|
description = "Path to api key secret file.";
|
2023-11-15 21:44:47 +01:00
|
|
|
};
|
|
|
|
LogLevel = lib.mkOption {
|
|
|
|
type = lib.types.enum ["debug" "info"];
|
2023-12-04 09:33:16 +01:00
|
|
|
description = "Log level.";
|
2023-11-15 21:44:47 +01:00
|
|
|
default = "info";
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
Port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
description = "Port on which radarr listens to incoming requests.";
|
|
|
|
default = 7878;
|
|
|
|
};
|
|
|
|
AnalyticsEnabled = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
description = "Wether to send anonymous data or not.";
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
BindAddress = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
};
|
|
|
|
UrlBase = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
EnableSsl = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
internal = true;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
AuthenticationMethod = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "External";
|
|
|
|
};
|
|
|
|
AuthenticationRequired = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "Enabled";
|
|
|
|
};
|
2023-11-15 21:44:47 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
|
|
|
sonarr = {
|
2024-05-23 23:28:08 +02:00
|
|
|
settingsFormat = shblib.formatXML { enclosingRoot = "Config"; };
|
2024-03-13 06:40:32 +01:00
|
|
|
moreOptions = {
|
|
|
|
settings = lib.mkOption {
|
|
|
|
description = "Specific options for sonarr.";
|
|
|
|
default = {};
|
|
|
|
type = lib.types.submodule {
|
|
|
|
freeformType = apps.sonarr.settingsFormat.type;
|
|
|
|
options = {
|
2024-05-23 23:28:08 +02:00
|
|
|
ApiKey = lib.mkOption {
|
2024-03-13 06:40:32 +01:00
|
|
|
type = shblib.secretFileType;
|
|
|
|
description = "Path to api key secret file.";
|
|
|
|
};
|
|
|
|
LogLevel = lib.mkOption {
|
|
|
|
type = lib.types.enum ["debug" "info"];
|
|
|
|
description = "Log level.";
|
|
|
|
default = "info";
|
|
|
|
};
|
|
|
|
Port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
description = "Port on which sonarr listens to incoming requests.";
|
|
|
|
default = 8989;
|
|
|
|
};
|
|
|
|
BindAddress = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "127.0.0.1";
|
|
|
|
};
|
|
|
|
UrlBase = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "";
|
|
|
|
};
|
|
|
|
EnableSsl = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
internal = true;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
AuthenticationMethod = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "External";
|
|
|
|
};
|
|
|
|
AuthenticationRequired = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
internal = true;
|
|
|
|
default = "Enabled";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
|
|
|
bazarr = {
|
2024-05-23 23:28:08 +02:00
|
|
|
settingsFormat = shblib.formatXML { enclosingRoot = "Config"; };
|
2024-03-13 06:40:32 +01:00
|
|
|
moreOptions = {
|
|
|
|
settings = lib.mkOption {
|
|
|
|
description = "Specific options for bazarr.";
|
|
|
|
default = {};
|
|
|
|
type = lib.types.submodule {
|
|
|
|
freeformType = apps.bazarr.settingsFormat.type;
|
|
|
|
options = {
|
|
|
|
LogLevel = lib.mkOption {
|
|
|
|
type = lib.types.enum ["debug" "info"];
|
|
|
|
description = "Log level.";
|
|
|
|
default = "info";
|
|
|
|
};
|
|
|
|
Port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
description = "Port on which bazarr listens to incoming requests.";
|
|
|
|
default = 6767;
|
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
|
|
|
readarr = {
|
2024-05-23 23:28:08 +02:00
|
|
|
settingsFormat = shblib.formatXML { enclosingRoot = "Config"; };
|
2024-03-13 06:40:32 +01:00
|
|
|
moreOptions = {
|
|
|
|
settings = lib.mkOption {
|
|
|
|
description = "Specific options for readarr.";
|
|
|
|
default = {};
|
|
|
|
type = lib.types.submodule {
|
|
|
|
freeformType = apps.readarr.settingsFormat.type;
|
|
|
|
options = {
|
|
|
|
LogLevel = lib.mkOption {
|
|
|
|
type = lib.types.enum ["debug" "info"];
|
|
|
|
description = "Log level.";
|
|
|
|
default = "info";
|
|
|
|
};
|
|
|
|
Port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
description = "Port on which readarr listens to incoming requests.";
|
|
|
|
default = 8787;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
|
|
|
lidarr = {
|
2024-05-23 23:28:08 +02:00
|
|
|
settingsFormat = shblib.formatXML { enclosingRoot = "Config"; };
|
2024-03-13 06:40:32 +01:00
|
|
|
moreOptions = {
|
|
|
|
settings = lib.mkOption {
|
|
|
|
description = "Specific options for lidarr.";
|
|
|
|
default = {};
|
|
|
|
type = lib.types.submodule {
|
|
|
|
freeformType = apps.lidarr.settingsFormat.type;
|
|
|
|
options = {
|
|
|
|
LogLevel = lib.mkOption {
|
|
|
|
type = lib.types.enum ["debug" "info"];
|
|
|
|
description = "Log level.";
|
|
|
|
default = "info";
|
|
|
|
};
|
|
|
|
Port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
description = "Port on which lidarr listens to incoming requests.";
|
|
|
|
default = 8686;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
2023-10-13 07:23:58 +02:00
|
|
|
jackett = {
|
|
|
|
settingsFormat = pkgs.formats.json {};
|
|
|
|
moreOptions = {
|
|
|
|
settings = lib.mkOption {
|
2023-11-30 21:06:41 +01:00
|
|
|
description = "Specific options for jackett.";
|
2023-11-08 21:27:47 +01:00
|
|
|
default = {};
|
2023-10-13 07:23:58 +02:00
|
|
|
type = lib.types.submodule {
|
|
|
|
freeformType = apps.jackett.settingsFormat.type;
|
|
|
|
options = {
|
2024-05-23 23:28:08 +02:00
|
|
|
ApiKey = lib.mkOption {
|
2024-03-13 06:40:32 +01:00
|
|
|
type = shblib.secretFileType;
|
2023-11-30 21:06:41 +01:00
|
|
|
description = "Path to api key secret file.";
|
2023-10-13 07:23:58 +02:00
|
|
|
};
|
|
|
|
FlareSolverrUrl = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
2023-11-30 21:06:41 +01:00
|
|
|
description = "FlareSolverr endpoint.";
|
2023-10-13 07:23:58 +02:00
|
|
|
default = null;
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
OmdbApiKey = lib.mkOption {
|
|
|
|
type = lib.types.nullOr shblib.secretFileType;
|
2023-12-04 09:33:16 +01:00
|
|
|
description = "File containing the Open Movie Database API key.";
|
2023-10-13 07:23:58 +02:00
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
ProxyType = lib.mkOption {
|
|
|
|
type = lib.types.enum [ "-1" "0" "1" "2" ];
|
2023-11-30 21:06:41 +01:00
|
|
|
default = "-1";
|
2023-10-13 07:23:58 +02:00
|
|
|
description = ''
|
|
|
|
-1 = disabled
|
|
|
|
0 = HTTP
|
|
|
|
1 = SOCKS4
|
|
|
|
2 = SOCKS5
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
ProxyUrl = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.str;
|
2023-12-04 09:33:16 +01:00
|
|
|
description = "URL of the proxy. Ignored if ProxyType is set to -1";
|
2023-10-13 07:23:58 +02:00
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
ProxyPort = lib.mkOption {
|
|
|
|
type = lib.types.nullOr lib.types.port;
|
2023-12-04 09:33:16 +01:00
|
|
|
description = "Port of the proxy. Ignored if ProxyType is set to -1";
|
2023-10-13 07:23:58 +02:00
|
|
|
default = null;
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
Port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
|
|
|
description = "Port on which jackett listens to incoming requests.";
|
|
|
|
default = 9117;
|
|
|
|
readOnly = true;
|
|
|
|
};
|
|
|
|
AllowExternal = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
internal = true;
|
|
|
|
default = false;
|
|
|
|
};
|
|
|
|
UpdateDisabled = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
internal = true;
|
|
|
|
default = true;
|
|
|
|
};
|
2023-10-13 07:23:58 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
|
|
|
|
2024-05-25 00:01:45 +02:00
|
|
|
vhosts = { extraBypassResources ? [] }: c: {
|
2024-03-13 06:40:32 +01:00
|
|
|
inherit (c) subdomain domain authEndpoint ssl;
|
|
|
|
|
|
|
|
upstream = "http://127.0.0.1:${toString c.settings.Port}";
|
|
|
|
autheliaRules = lib.optionals (!(isNull c.authEndpoint)) [
|
|
|
|
{
|
|
|
|
domain = "${c.subdomain}.${c.domain}";
|
|
|
|
policy = "bypass";
|
|
|
|
resources = extraBypassResources ++ [
|
|
|
|
"^/api.*"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
{
|
|
|
|
domain = "${c.subdomain}.${c.domain}";
|
|
|
|
policy = "two_factor";
|
|
|
|
subject = ["group:arr_user"];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
backup = name: {
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${config.shb.arr.${name}.dataDir}' 0750 ${config.services.${name}.user} ${config.services.${name}.group} - -"
|
|
|
|
];
|
|
|
|
users.groups.${name} = {
|
|
|
|
members = [ "backup" ];
|
|
|
|
};
|
|
|
|
systemd.services.${name}.serviceConfig = {
|
|
|
|
# Setup permissions needed for backups, as the backup user is member of the jellyfin group.
|
|
|
|
UMask = lib.mkForce "0027";
|
|
|
|
StateDirectoryMode = lib.mkForce "0750";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-09-24 22:31:21 +02:00
|
|
|
appOption = name: c: lib.nameValuePair name (lib.mkOption {
|
|
|
|
description = "Configuration for ${name}";
|
2023-11-08 21:27:47 +01:00
|
|
|
default = {};
|
2023-09-24 22:31:21 +02:00
|
|
|
type = lib.types.submodule {
|
|
|
|
options = {
|
2023-11-30 21:06:41 +01:00
|
|
|
enable = lib.mkEnableOption name;
|
2023-09-24 22:31:21 +02:00
|
|
|
|
|
|
|
subdomain = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Subdomain under which ${name} will be served.";
|
|
|
|
example = name;
|
|
|
|
};
|
|
|
|
|
|
|
|
domain = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = "Domain under which ${name} will be served.";
|
2023-11-30 21:06:41 +01:00
|
|
|
example = "example.com";
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2023-11-30 21:06:41 +01:00
|
|
|
description = "Directory where ${name} stores data.";
|
2023-09-24 22:31:21 +02:00
|
|
|
default = "/var/lib/${name}";
|
|
|
|
};
|
|
|
|
|
2024-03-13 06:40:32 +01:00
|
|
|
ssl = lib.mkOption {
|
|
|
|
description = "Path to SSL files";
|
|
|
|
type = lib.types.nullOr contracts.ssl.certs;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
|
2023-11-30 21:48:57 +01:00
|
|
|
authEndpoint = lib.mkOption {
|
2023-11-08 21:27:47 +01:00
|
|
|
type = lib.types.nullOr lib.types.str;
|
|
|
|
default = null;
|
2023-11-30 21:06:41 +01:00
|
|
|
description = "Endpoint to the SSO provider. Leave null to not have SSO configured.";
|
2023-09-24 22:31:21 +02:00
|
|
|
example = "https://authelia.example.com";
|
|
|
|
};
|
2023-11-17 08:00:53 +01:00
|
|
|
|
|
|
|
backupCfg = lib.mkOption {
|
|
|
|
type = lib.types.anything;
|
|
|
|
description = "Backup configuration for ${name}.";
|
|
|
|
default = {};
|
|
|
|
example = {
|
|
|
|
backend = "restic";
|
|
|
|
repositories = [];
|
|
|
|
};
|
|
|
|
};
|
2023-10-13 07:23:58 +02:00
|
|
|
} // (c.moreOptions or {});
|
2023-09-24 22:31:21 +02:00
|
|
|
};
|
|
|
|
});
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.shb.arr = lib.listToAttrs (lib.mapAttrsToList appOption apps);
|
|
|
|
|
2024-04-11 08:52:24 +02:00
|
|
|
config = lib.mkMerge [
|
2024-04-09 16:16:50 +02:00
|
|
|
(lib.mkIf cfg.radarr.enable (
|
|
|
|
let
|
|
|
|
cfg' = cfg.radarr;
|
|
|
|
isSSOEnabled = !(isNull cfg'.authEndpoint);
|
|
|
|
in
|
|
|
|
{
|
2024-03-13 06:40:32 +01:00
|
|
|
services.nginx.enable = true;
|
|
|
|
|
|
|
|
services.radarr = {
|
2023-09-27 05:13:08 +02:00
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/radarr";
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
|
|
|
|
systemd.services.radarr.preStart = shblib.replaceSecrets {
|
2024-04-09 16:16:50 +02:00
|
|
|
userConfig = cfg'.settings
|
|
|
|
// (lib.optionalAttrs isSSOEnabled {
|
|
|
|
AuthenticationRequired = "DisabledForLocalAddresses";
|
|
|
|
AuthenticationMethod = "External";
|
|
|
|
});
|
2024-03-13 06:40:32 +01:00
|
|
|
resultPath = "${config.services.radarr.dataDir}/config.xml";
|
2024-05-23 23:28:08 +02:00
|
|
|
generator = shblib.replaceSecretsFormatAdapter apps.radarr.settingsFormat;
|
2023-11-15 21:44:47 +01:00
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-05-25 00:01:45 +02:00
|
|
|
shb.nginx.vhosts = [ (vhosts {} cfg') ];
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
shb.backup.instances.radarr = cfg'.backupCfg // {
|
2024-03-13 06:40:32 +01:00
|
|
|
sourceDirectories = [
|
2024-04-09 16:16:50 +02:00
|
|
|
cfg'.dataDir
|
2024-03-13 06:40:32 +01:00
|
|
|
];
|
|
|
|
excludePatterns = [".db-shm" ".db-wal" ".mono"];
|
|
|
|
};
|
2024-04-11 08:52:24 +02:00
|
|
|
}))
|
|
|
|
(lib.mkIf cfg.radarr.enable (backup "radarr"))
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
(lib.mkIf cfg.sonarr.enable (
|
|
|
|
let
|
|
|
|
cfg' = cfg.sonarr;
|
|
|
|
isSSOEnabled = !(isNull cfg'.authEndpoint);
|
|
|
|
in
|
|
|
|
{
|
2024-03-13 06:40:32 +01:00
|
|
|
services.nginx.enable = true;
|
|
|
|
|
|
|
|
services.sonarr = {
|
2023-09-27 05:13:08 +02:00
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/sonarr";
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
users.users.sonarr = {
|
2023-09-27 05:13:08 +02:00
|
|
|
extraGroups = [ "media" ];
|
|
|
|
};
|
2024-04-09 16:16:50 +02:00
|
|
|
|
2024-03-13 06:40:32 +01:00
|
|
|
systemd.services.sonarr.preStart = shblib.replaceSecrets {
|
2024-04-09 16:16:50 +02:00
|
|
|
userConfig = cfg'.settings
|
|
|
|
// (lib.optionalAttrs isSSOEnabled {
|
|
|
|
AuthenticationRequired = "DisabledForLocalAddresses";
|
|
|
|
AuthenticationMethod = "External";
|
|
|
|
});
|
2024-03-13 06:40:32 +01:00
|
|
|
resultPath = "${config.services.sonarr.dataDir}/config.xml";
|
|
|
|
generator = apps.sonarr.settingsFormat.generate;
|
|
|
|
};
|
|
|
|
|
2024-05-25 00:01:45 +02:00
|
|
|
shb.nginx.vhosts = [ (vhosts {} cfg') ];
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
shb.backup.instances.sonarr = cfg'.backupCfg // {
|
2024-03-13 06:40:32 +01:00
|
|
|
sourceDirectories = [
|
2024-04-09 16:16:50 +02:00
|
|
|
cfg'.dataDir
|
2024-03-13 06:40:32 +01:00
|
|
|
];
|
|
|
|
excludePatterns = [".db-shm" ".db-wal" ".mono"];
|
|
|
|
};
|
2024-04-11 08:52:24 +02:00
|
|
|
}))
|
|
|
|
(lib.mkIf cfg.sonarr.enable (backup "sonarr"))
|
2023-09-26 08:15:36 +02:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
(lib.mkIf cfg.bazarr.enable (
|
|
|
|
let
|
|
|
|
cfg' = cfg.bazarr;
|
2024-04-11 08:52:24 +02:00
|
|
|
isSSOEnabled = !(isNull cfg'.authEndpoint);
|
2024-04-09 16:16:50 +02:00
|
|
|
in
|
|
|
|
{
|
2024-03-13 06:40:32 +01:00
|
|
|
services.bazarr = {
|
2023-09-27 05:13:08 +02:00
|
|
|
enable = true;
|
2024-04-09 16:16:50 +02:00
|
|
|
listenPort = cfg'.settings.Port;
|
2023-09-27 05:13:08 +02:00
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
users.users.bazarr = {
|
2023-11-08 21:27:47 +01:00
|
|
|
extraGroups = [ "media" ];
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
systemd.services.bazarr.preStart = shblib.replaceSecrets {
|
2024-04-11 08:52:24 +02:00
|
|
|
userConfig = cfg'.settings
|
|
|
|
// (lib.optionalAttrs isSSOEnabled {
|
|
|
|
AuthenticationRequired = "DisabledForLocalAddresses";
|
|
|
|
AuthenticationMethod = "External";
|
|
|
|
});
|
|
|
|
resultPath = "/var/lib/bazarr/config.xml";
|
2024-03-13 06:40:32 +01:00
|
|
|
generator = apps.bazarr.settingsFormat.generate;
|
|
|
|
};
|
|
|
|
|
2024-05-25 00:01:45 +02:00
|
|
|
shb.nginx.vhosts = [ (vhosts {} cfg') ];
|
2023-09-24 22:31:21 +02:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
shb.backup.instances.bazarr = cfg'.backupCfg // {
|
2024-03-13 06:40:32 +01:00
|
|
|
sourceDirectories = [
|
2024-04-09 16:16:50 +02:00
|
|
|
cfg'.dataDir
|
2024-03-13 06:40:32 +01:00
|
|
|
];
|
|
|
|
excludePatterns = [".db-shm" ".db-wal" ".mono"];
|
|
|
|
};
|
2024-04-11 08:52:24 +02:00
|
|
|
}))
|
2024-04-18 01:06:29 +02:00
|
|
|
(lib.mkIf cfg.bazarr.enable (backup "bazarr"))
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
(lib.mkIf cfg.readarr.enable (
|
|
|
|
let
|
|
|
|
cfg' = cfg.readarr;
|
|
|
|
in
|
|
|
|
{
|
2024-03-13 06:40:32 +01:00
|
|
|
services.readarr = {
|
2023-09-27 05:13:08 +02:00
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/readarr";
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
users.users.readarr = {
|
2023-09-30 08:19:39 +02:00
|
|
|
extraGroups = [ "media" ];
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
systemd.services.readarr.preStart = shblib.replaceSecrets {
|
2024-04-09 16:16:50 +02:00
|
|
|
userConfig = cfg'.settings;
|
2024-03-13 06:40:32 +01:00
|
|
|
resultPath = "${config.services.readarr.dataDir}/config.xml";
|
|
|
|
generator = apps.readarr.settingsFormat.generate;
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
|
2024-05-25 00:01:45 +02:00
|
|
|
shb.nginx.vhosts = [ (vhosts {} cfg') ];
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
shb.backup.instances.readarr = cfg'.backupCfg // {
|
2024-03-13 06:40:32 +01:00
|
|
|
sourceDirectories = [
|
2024-04-09 16:16:50 +02:00
|
|
|
cfg'.dataDir
|
2024-03-13 06:40:32 +01:00
|
|
|
];
|
|
|
|
excludePatterns = [".db-shm" ".db-wal" ".mono"];
|
|
|
|
};
|
2024-04-11 08:52:24 +02:00
|
|
|
}))
|
2024-04-18 01:06:29 +02:00
|
|
|
(lib.mkIf cfg.readarr.enable (backup "readarr"))
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
(lib.mkIf cfg.lidarr.enable (
|
|
|
|
let
|
|
|
|
cfg' = cfg.lidarr;
|
2024-04-11 08:52:24 +02:00
|
|
|
isSSOEnabled = !(isNull cfg'.authEndpoint);
|
2024-04-09 16:16:50 +02:00
|
|
|
in
|
|
|
|
{
|
2024-03-13 06:40:32 +01:00
|
|
|
services.lidarr = {
|
2023-09-27 05:13:08 +02:00
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/lidarr";
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
users.users.lidarr = {
|
2023-09-30 08:19:39 +02:00
|
|
|
extraGroups = [ "media" ];
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
systemd.services.lidarr.preStart = shblib.replaceSecrets {
|
2024-04-11 08:52:24 +02:00
|
|
|
userConfig = cfg'.settings
|
|
|
|
// (lib.optionalAttrs isSSOEnabled {
|
|
|
|
AuthenticationRequired = "DisabledForLocalAddresses";
|
|
|
|
AuthenticationMethod = "External";
|
|
|
|
});
|
2024-03-13 06:40:32 +01:00
|
|
|
resultPath = "${config.services.lidarr.dataDir}/config.xml";
|
|
|
|
generator = apps.lidarr.settingsFormat.generate;
|
|
|
|
};
|
2023-09-24 22:31:21 +02:00
|
|
|
|
2024-05-25 00:01:45 +02:00
|
|
|
shb.nginx.vhosts = [ (vhosts {} cfg') ];
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
shb.backup.instances.lidarr = cfg'.backupCfg // {
|
2024-03-13 06:40:32 +01:00
|
|
|
sourceDirectories = [
|
2024-04-09 16:16:50 +02:00
|
|
|
cfg'.dataDir
|
2024-03-13 06:40:32 +01:00
|
|
|
];
|
|
|
|
excludePatterns = [".db-shm" ".db-wal" ".mono"];
|
|
|
|
};
|
2024-04-11 08:52:24 +02:00
|
|
|
}))
|
2024-04-18 01:06:29 +02:00
|
|
|
(lib.mkIf cfg.lidarr.enable (backup "lidarr"))
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
(lib.mkIf cfg.jackett.enable (
|
|
|
|
let
|
|
|
|
cfg' = cfg.jackett;
|
|
|
|
in
|
|
|
|
{
|
2024-03-13 06:40:32 +01:00
|
|
|
services.jackett = {
|
2023-10-13 07:23:58 +02:00
|
|
|
enable = true;
|
|
|
|
dataDir = "/var/lib/jackett";
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
users.users.jackett = {
|
2023-10-13 07:23:58 +02:00
|
|
|
extraGroups = [ "media" ];
|
|
|
|
};
|
2024-03-13 06:40:32 +01:00
|
|
|
systemd.services.jackett.preStart = shblib.replaceSecrets {
|
2024-05-23 23:28:08 +02:00
|
|
|
userConfig = shblib.renameAttrName cfg'.settings "ApiKey" "APIKey";
|
2024-04-11 08:52:24 +02:00
|
|
|
resultPath = "${config.services.jackett.dataDir}/ServerConfig.json";
|
2024-03-13 06:40:32 +01:00
|
|
|
generator = apps.jackett.settingsFormat.generate;
|
|
|
|
};
|
|
|
|
|
2024-05-25 00:01:45 +02:00
|
|
|
shb.nginx.vhosts = [ (vhosts {
|
2024-03-13 06:40:32 +01:00
|
|
|
extraBypassResources = [ "^/dl.*" ];
|
2024-04-09 16:16:50 +02:00
|
|
|
} cfg') ];
|
2024-03-13 06:40:32 +01:00
|
|
|
|
2024-04-09 16:16:50 +02:00
|
|
|
shb.backup.instances.jackett = cfg'.backupCfg // {
|
2024-03-13 06:40:32 +01:00
|
|
|
sourceDirectories = [
|
2024-04-09 16:16:50 +02:00
|
|
|
cfg'.dataDir
|
2024-03-13 06:40:32 +01:00
|
|
|
];
|
|
|
|
excludePatterns = [".db-shm" ".db-wal" ".mono"];
|
|
|
|
};
|
2024-04-11 08:52:24 +02:00
|
|
|
}))
|
2024-04-18 01:06:29 +02:00
|
|
|
(lib.mkIf cfg.jackett.enable (backup "jackett"))
|
2024-04-11 08:52:24 +02:00
|
|
|
];
|
2023-09-24 22:31:21 +02:00
|
|
|
}
|