servarr: added qbittorrent and sonarr

This commit is contained in:
Tigor Hutasuhut 2024-06-25 22:45:00 +07:00
parent 1356d52050
commit 8aea0d6f44
8 changed files with 199 additions and 3 deletions

View file

@ -1,4 +1,7 @@
{ lib, ... }:
{ config, lib, ... }:
let
inherit (lib) mkOption mkEnableOption types;
in
{
options.profile.podman = {
enable = lib.mkEnableOption "podman";
@ -9,5 +12,33 @@
redmage.enable = lib.mkEnableOption "redmage podman";
redmage-demo.enable = lib.mkEnableOption "redmage-demo podman";
qbittorrent.enable = lib.mkEnableOption "qbittorrent podman";
servarr = {
enable = mkEnableOption "servarr group";
qbittorrent.enable = mkOption {
type = types.bool;
default = config.profile.podman.servarr.enable;
};
real-debrid-manager.enable = mkOption {
type = types.bool;
default = config.profile.podman.servarr.enable;
};
prowlarr.enable = mkOption {
type = types.bool;
default = config.profile.podman.servarr.enable;
};
radar.enable = mkOption {
type = types.bool;
default = config.profile.podman.servarr.enable;
};
sonarr.enable = mkOption {
type = types.bool;
default = config.profile.podman.servarr.enable;
};
bazarr.enable = mkOption {
type = types.bool;
default = config.profile.podman.servarr.enable;
};
};
};
}

View file

@ -31,6 +31,7 @@
redmage.enable = true;
redmage-demo.enable = true;
qbittorrent.enable = true;
servarr.enable = true;
};
docker = {

View file

@ -30,8 +30,8 @@ in
bantime = "24h"; # Ban IPs for one day on the first ban
bantime-increment = {
enable = true; # Enable increment of bantime after each violation
formula = "ban.Time * math.exp(float(ban.Count+1)*banFactor)/math.exp(1*banFactor)";
# multipliers = "1 2 4 8 16 32 64";
# formula = "ban.Time * math.exp(float(ban.Count+1)*banFactor)/math.exp(1*banFactor)";
multipliers = "1 2 4 8 16 32 64";
maxtime = "168h"; # Do not ban for more than 1 week
overalljails = true; # Calculate the bantime based on all the violations
};

View file

@ -47,5 +47,6 @@ in
./redmage.nix
./suwayomi.nix
./ytptube.nix
./servarr
];
}

View file

@ -0,0 +1,8 @@
{ ... }:
{
imports = [
# ./real-debrid-manager.nix
./qbittorrent.nix
./sonarr.nix
];
}

View file

@ -0,0 +1,56 @@
{ config, lib, ... }:
let
podman = config.profile.podman;
qbittorrent = podman.servarr.qbittorrent;
name = "qbittorrent-servarr";
ip = "10.88.2.2";
image = "lscr.io/linuxserver/qbittorrent:latest";
root = "/nas/mediaserver/servarr";
configVolume = "${root}/qbittorrent";
mediaVolume = "${root}/data/torrents";
domain = "${name}.tigor.web.id";
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
inherit (lib) mkIf;
in
{
config = mkIf (podman.enable && qbittorrent.enable) {
services.caddy.virtualHosts.${domain}.extraConfig = ''
reverse_proxy ${ip}:8080
'';
system.activationScripts."podman-${name}" = ''
mkdir -p ${configVolume} ${mediaVolume}
chown ${uid}:${gid} ${mediaVolume} ${configVolume}
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
environment = {
PUID = uid;
PGID = gid;
TZ = "Asia/Jakarta";
WEBUI_PORT = "8080";
TORRENTING_PORT = "6882";
};
volumes = [
"${configVolume}:/config"
"${mediaVolume}:/data/torrents"
];
ports = [
"6882:6882"
"6882:6882/udp"
];
extraOptions = [
"--ip=${ip}"
"--network=podman"
];
labels = {
"io.containers.autoupdate" = "registry";
};
};
};
}

View file

@ -0,0 +1,49 @@
{ config, lib, ... }:
let
podman = config.profile.podman;
cfg = podman.servarr.real-debrid-manager;
name = "real-debrid-manager";
ip = "10.88.2.1";
image = "docker.io/hyperbunny77/realdebridmanager:latest";
volume = "/nas/mediaserver/servarr/real-debrid-manager";
domain = "rdm.tigor.web.id";
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
inherit (lib) mkIf;
in
{
config = mkIf (podman.enable && cfg.enable) {
services.caddy.${domain}.extraConfig = ''
reverse_proxy ${ip}:5000
'';
system.activationScripts."podman-${name}" = ''
mkdir -p ${volume}/{config,downloads,watch}
chown -R ${uid}:${gid} ${volume}/{config,downloads,watch}
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
user = "${uid}:${gid}";
enviroment = {
TZ = "Asia/Jakarta";
rdmport = "5000";
};
volumes = [
"${volume}/config:/config"
"${volume}/downloads:/downloads"
"${volume}/watch:/watch"
];
extraOptions = [
"--network=podman"
"--ip=${ip}"
];
labels = {
"io.containers.autoupdate" = "registry";
};
};
};
}

View file

@ -0,0 +1,50 @@
{ config, lib, ... }:
let
podman = config.profile.podman;
sonarr = podman.servarr.sonarr;
name = "sonarr";
ip = "10.88.2.3";
image = "lscr.io/linuxserver/sonarr:latest";
root = "/nas/mediaserver/servarr";
configVolume = "${root}/sonarr";
mediaVolume = "${root}/data";
domain = "${name}.tigor.web.id";
user = config.profile.user;
uid = toString user.uid;
gid = toString user.gid;
inherit (lib) mkIf;
in
{
config = mkIf (podman.enable && sonarr.enable) {
services.caddy.virtualHosts.${domain}.extraConfig = ''
reverse_proxy ${ip}:8989
'';
system.activationScripts."podman-${name}" = ''
mkdir -p ${configVolume} ${mediaVolume}
chown ${uid}:${gid} ${mediaVolume} ${configVolume}
'';
virtualisation.oci-containers.containers.${name} = {
inherit image;
hostname = name;
autoStart = true;
environment = {
PUID = uid;
PGID = gid;
TZ = "Asia/Jakarta";
};
volumes = [
"${configVolume}:/config"
"${mediaVolume}:/data"
];
extraOptions = [
"--ip=${ip}"
"--network=podman"
];
labels = {
"io.containers.autoupdate" = "registry";
};
};
};
}