diff --git a/options/podman.nix b/options/podman.nix index 02aa8cd..eace678 100644 --- a/options/podman.nix +++ b/options/podman.nix @@ -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; + }; + }; }; } diff --git a/profiles/homeserver.nix b/profiles/homeserver.nix index 44c9b0b..3910ac3 100644 --- a/profiles/homeserver.nix +++ b/profiles/homeserver.nix @@ -31,6 +31,7 @@ redmage.enable = true; redmage-demo.enable = true; qbittorrent.enable = true; + servarr.enable = true; }; docker = { diff --git a/system/modules/openssh.nix b/system/modules/openssh.nix index 78b30fa..2912d30 100644 --- a/system/modules/openssh.nix +++ b/system/modules/openssh.nix @@ -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 }; diff --git a/system/podman/default.nix b/system/podman/default.nix index da3fddc..70eea0b 100644 --- a/system/podman/default.nix +++ b/system/podman/default.nix @@ -47,5 +47,6 @@ in ./redmage.nix ./suwayomi.nix ./ytptube.nix + ./servarr ]; } diff --git a/system/podman/servarr/default.nix b/system/podman/servarr/default.nix new file mode 100644 index 0000000..5ca75f3 --- /dev/null +++ b/system/podman/servarr/default.nix @@ -0,0 +1,8 @@ +{ ... }: +{ + imports = [ + # ./real-debrid-manager.nix + ./qbittorrent.nix + ./sonarr.nix + ]; +} diff --git a/system/podman/servarr/qbittorrent.nix b/system/podman/servarr/qbittorrent.nix new file mode 100644 index 0000000..349696c --- /dev/null +++ b/system/podman/servarr/qbittorrent.nix @@ -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"; + }; + }; + }; +} diff --git a/system/podman/servarr/real-debrid-manager.nix b/system/podman/servarr/real-debrid-manager.nix new file mode 100644 index 0000000..a53e0f0 --- /dev/null +++ b/system/podman/servarr/real-debrid-manager.nix @@ -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"; + }; + }; + }; +} diff --git a/system/podman/servarr/sonarr.nix b/system/podman/servarr/sonarr.nix new file mode 100644 index 0000000..1870e77 --- /dev/null +++ b/system/podman/servarr/sonarr.nix @@ -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"; + }; + }; + }; +}