From 6c610ffe006b019f130a416df1d1e8a9457eefaf Mon Sep 17 00:00:00 2001 From: Tigor Hutasuhut Date: Tue, 18 Jun 2024 20:24:28 +0700 Subject: [PATCH] podman: added qbittorrent container --- options/podman.nix | 1 + profiles/homeserver.nix | 1 + system/podman/default.nix | 1 + system/podman/qbittorrent.nix | 53 +++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) create mode 100644 system/podman/qbittorrent.nix diff --git a/options/podman.nix b/options/podman.nix index d3e962f..02aa8cd 100644 --- a/options/podman.nix +++ b/options/podman.nix @@ -8,5 +8,6 @@ ytptube.enable = lib.mkEnableOption "metube podman"; redmage.enable = lib.mkEnableOption "redmage podman"; redmage-demo.enable = lib.mkEnableOption "redmage-demo podman"; + qbittorrent.enable = lib.mkEnableOption "qbittorrent podman"; }; } diff --git a/profiles/homeserver.nix b/profiles/homeserver.nix index 226cc40..5f70888 100644 --- a/profiles/homeserver.nix +++ b/profiles/homeserver.nix @@ -30,6 +30,7 @@ ytptube.enable = true; redmage.enable = true; redmage-demo.enable = true; + qbittorrent.enable = true; }; docker = { diff --git a/system/podman/default.nix b/system/podman/default.nix index c4fc0fb..2d6af9c 100644 --- a/system/podman/default.nix +++ b/system/podman/default.nix @@ -44,6 +44,7 @@ in ./pihole.nix ./redmage-demo.nix ./redmage.nix + ./qbittorrent.nix ./suwayomi.nix ./ytptube.nix ]; diff --git a/system/podman/qbittorrent.nix b/system/podman/qbittorrent.nix new file mode 100644 index 0000000..8e4ff7c --- /dev/null +++ b/system/podman/qbittorrent.nix @@ -0,0 +1,53 @@ +{ config, lib, ... }: +let + name = "qbittorrent"; + domain = "${name}.tigor.web.id"; + podman = config.profile.podman; + qbittorrent = podman.qbittorrent; + inherit (lib) mkIf; + ip = "10.88.0.7"; + image = "lscr.io/linuxserver/qbittorrent:latest"; + volume = "/nas/torrents"; + user = config.profile.user; + uid = toString user.uid; + gid = toString user.gid; +in +{ + config = mkIf (podman.enable && qbittorrent.enable) { + services.caddy.virtualHosts.${domain}.extraConfig = '' + reverse_proxy ${ip}:8080 + ''; + + system.activationScripts."podman-${name}" = '' + mkdir -p ${volume}/{config,downloads,progress,auto} + chown ${uid}:${gid} ${volume} ${volume}/{config,downloads,progress,auto} + ''; + + virtualisation.oci-containers.containers.${name} = { + inherit image; + autoStart = true; + environment = { + PUID = uid; + PGID = gid; + TZ = "Asia/Jakarta"; + WEBUI_PORT = "8080"; + TORRENTING_PORT = "6881"; + }; + volumes = [ + "${volume}/config:/config" + "${volume}/downloads:/downloads" + "${volume}/progress:/progress" + "${volume}/auto:/auto" + ]; + ports = [ + "6881:6881" + "6881:6881/udp" + ]; + extraOptions = [ + "--ip=${ip}" + "--network=podman" + ]; + }; + }; +} +