lib: add mkCaddyReverseProxy, mkFail2banJail, mkGrafanaAnnotationService, extractArrApiKey
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
service_configs,
|
||||
...
|
||||
}:
|
||||
@@ -12,7 +13,6 @@ let
|
||||
|
||||
curl = "${pkgs.curl}/bin/curl";
|
||||
jq = "${pkgs.jq}/bin/jq";
|
||||
grep = "${pkgs.gnugrep}/bin/grep";
|
||||
|
||||
# Max items to search per cycle per category (missing + cutoff) per app
|
||||
maxPerCycle = 5;
|
||||
@@ -20,8 +20,8 @@ let
|
||||
searchScript = pkgs.writeShellScript "arr-search" ''
|
||||
set -euo pipefail
|
||||
|
||||
RADARR_KEY=$(${grep} -oP '(?<=<ApiKey>)[^<]+' ${radarrConfig})
|
||||
SONARR_KEY=$(${grep} -oP '(?<=<ApiKey>)[^<]+' ${sonarrConfig})
|
||||
RADARR_KEY=$(${lib.extractArrApiKey radarrConfig})
|
||||
SONARR_KEY=$(${lib.extractArrApiKey sonarrConfig})
|
||||
|
||||
search_radarr() {
|
||||
local endpoint="$1"
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
(lib.serviceFilePerms "bazarr" [
|
||||
"Z ${service_configs.bazarr.dataDir} 0700 ${config.services.bazarr.user} ${config.services.bazarr.group}"
|
||||
])
|
||||
(lib.mkCaddyReverseProxy {
|
||||
subdomain = "bazarr";
|
||||
port = service_configs.ports.private.bazarr.port;
|
||||
auth = true;
|
||||
})
|
||||
];
|
||||
|
||||
services.bazarr = {
|
||||
@@ -23,11 +28,6 @@
|
||||
listenPort = service_configs.ports.private.bazarr.port;
|
||||
};
|
||||
|
||||
services.caddy.virtualHosts."bazarr.${service_configs.https.domain}".extraConfig = ''
|
||||
import ${config.age.secrets.caddy_auth.path}
|
||||
reverse_proxy :${builtins.toString service_configs.ports.private.bazarr.port}
|
||||
'';
|
||||
|
||||
users.users.${config.services.bazarr.user}.extraGroups = [
|
||||
service_configs.media_group
|
||||
];
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
(lib.serviceFilePerms "jellyseerr" [
|
||||
"Z ${service_configs.jellyseerr.configDir} 0700 jellyseerr jellyseerr"
|
||||
])
|
||||
(lib.mkCaddyReverseProxy {
|
||||
subdomain = "jellyseerr";
|
||||
port = service_configs.ports.private.jellyseerr.port;
|
||||
})
|
||||
];
|
||||
|
||||
services.jellyseerr = {
|
||||
@@ -36,8 +40,4 @@
|
||||
|
||||
users.groups.jellyseerr = { };
|
||||
|
||||
services.caddy.virtualHosts."jellyseerr.${service_configs.https.domain}".extraConfig = ''
|
||||
# import ${config.age.secrets.caddy_auth.path}
|
||||
reverse_proxy :${builtins.toString service_configs.ports.private.jellyseerr.port}
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
(lib.serviceFilePerms "prowlarr" [
|
||||
"Z ${service_configs.prowlarr.dataDir} 0700 prowlarr prowlarr"
|
||||
])
|
||||
(lib.mkCaddyReverseProxy {
|
||||
subdomain = "prowlarr";
|
||||
port = service_configs.ports.private.prowlarr.port;
|
||||
auth = true;
|
||||
vpn = true;
|
||||
})
|
||||
];
|
||||
|
||||
services.prowlarr = {
|
||||
@@ -51,8 +57,4 @@
|
||||
ExecStart = lib.mkForce "${lib.getExe pkgs.prowlarr} -nobrowser -data=${service_configs.prowlarr.dataDir}";
|
||||
};
|
||||
|
||||
services.caddy.virtualHosts."prowlarr.${service_configs.https.domain}".extraConfig = ''
|
||||
import ${config.age.secrets.caddy_auth.path}
|
||||
reverse_proxy ${config.vpnNamespaces.wg.namespaceAddress}:${builtins.toString service_configs.ports.private.prowlarr.port}
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
(lib.serviceFilePerms "radarr" [
|
||||
"Z ${service_configs.radarr.dataDir} 0700 ${config.services.radarr.user} ${config.services.radarr.group}"
|
||||
])
|
||||
(lib.mkCaddyReverseProxy {
|
||||
subdomain = "radarr";
|
||||
port = service_configs.ports.private.radarr.port;
|
||||
auth = true;
|
||||
})
|
||||
];
|
||||
|
||||
services.radarr = {
|
||||
@@ -25,11 +30,6 @@
|
||||
settings.update.mechanism = "external";
|
||||
};
|
||||
|
||||
services.caddy.virtualHosts."radarr.${service_configs.https.domain}".extraConfig = ''
|
||||
import ${config.age.secrets.caddy_auth.path}
|
||||
reverse_proxy :${builtins.toString service_configs.ports.private.radarr.port}
|
||||
'';
|
||||
|
||||
users.users.${config.services.radarr.user}.extraGroups = [
|
||||
service_configs.media_group
|
||||
];
|
||||
|
||||
@@ -13,8 +13,8 @@ let
|
||||
# Runs as root (via + prefix) after the NixOS module writes config.json.
|
||||
# Extracts API keys from radarr/sonarr config.xml and injects them via jq.
|
||||
injectApiKeys = pkgs.writeShellScript "recyclarr-inject-api-keys" ''
|
||||
RADARR_KEY=$(${lib.getExe pkgs.gnugrep} -oP '(?<=<ApiKey>)[^<]+' ${radarrConfig})
|
||||
SONARR_KEY=$(${lib.getExe pkgs.gnugrep} -oP '(?<=<ApiKey>)[^<]+' ${sonarrConfig})
|
||||
RADARR_KEY=$(${lib.extractArrApiKey radarrConfig})
|
||||
SONARR_KEY=$(${lib.extractArrApiKey sonarrConfig})
|
||||
${pkgs.jq}/bin/jq \
|
||||
--arg rk "$RADARR_KEY" \
|
||||
--arg sk "$SONARR_KEY" \
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
(lib.serviceFilePerms "sonarr" [
|
||||
"Z ${service_configs.sonarr.dataDir} 0700 ${config.services.sonarr.user} ${config.services.sonarr.group}"
|
||||
])
|
||||
(lib.mkCaddyReverseProxy {
|
||||
subdomain = "sonarr";
|
||||
port = service_configs.ports.private.sonarr.port;
|
||||
auth = true;
|
||||
})
|
||||
];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
@@ -31,11 +36,6 @@
|
||||
settings.update.mechanism = "external";
|
||||
};
|
||||
|
||||
services.caddy.virtualHosts."sonarr.${service_configs.https.domain}".extraConfig = ''
|
||||
import ${config.age.secrets.caddy_auth.path}
|
||||
reverse_proxy :${builtins.toString service_configs.ports.private.sonarr.port}
|
||||
'';
|
||||
|
||||
users.users.${config.services.sonarr.user}.extraGroups = [
|
||||
service_configs.media_group
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user