diff --git a/common/icons/qbittorrent.png b/common/icons/qbittorrent.png new file mode 100644 index 0000000..7b2da1f Binary files /dev/null and b/common/icons/qbittorrent.png differ diff --git a/docs/ports.md b/docs/ports.md index 3580bba..3602123 100644 --- a/docs/ports.md +++ b/docs/ports.md @@ -20,3 +20,4 @@ The idea is to always use consecutive ports, but never go back and try to recycl | 8414 | [invidious](../hosts/nixos/lapetus/services/invidious.nix) | | 8415 | [radicale](../hosts/nixos/lapetus/services/radicale.nix) | | 8416 | [redlib](../hosts/nixos/lapetus/services/redlib.nix) | +| 8417 | [qbittorrent](../hosts/nixos/lapetus/services/qbittorrent.nix) | diff --git a/hosts/nixos/lapetus/default.nix b/hosts/nixos/lapetus/default.nix index 9b5dba9..15fd12b 100644 --- a/hosts/nixos/lapetus/default.nix +++ b/hosts/nixos/lapetus/default.nix @@ -22,6 +22,7 @@ ./services/ddclient.nix ./services/redlib.nix ./services/jellyfin.nix + ./services/qbittorrent.nix ./filesystems ./hardware ]; diff --git a/hosts/nixos/lapetus/services/homer.nix b/hosts/nixos/lapetus/services/homer.nix index 20b5ea9..420b5d3 100644 --- a/hosts/nixos/lapetus/services/homer.nix +++ b/hosts/nixos/lapetus/services/homer.nix @@ -144,10 +144,16 @@ in logo = icon "commafeed.png"; url = "https://rss.moonythm.dev"; } + { + name = "Qbittorrent"; + subtitle = "Torrent client"; + logo = icon "jellyfin.png"; + url = "https://qbit.moonythm.dev"; + } { name = "Jellyfin"; subtitle = "Media server"; - logo = icon "jellyfin.png"; + logo = icon "qbittorrent.png"; url = "https://media.moonythm.dev"; } ]; diff --git a/hosts/nixos/lapetus/services/qbittorrent.nix b/hosts/nixos/lapetus/services/qbittorrent.nix new file mode 100644 index 0000000..96be303 --- /dev/null +++ b/hosts/nixos/lapetus/services/qbittorrent.nix @@ -0,0 +1,44 @@ +{ config, pkgs, ... }: +let + port = 8417; + dataDir = "/persist/data/home/adrielus/media"; + configDir = "/persist/state/var/lib/qbittorrent"; + vpnConfigDir = "/persist/state/var/lib/openvpn"; +in +{ + imports = [ ../../common/optional/services/nginx.nix ]; + + services.nginx.virtualHosts."qbit.moonythm.dev" = + config.satellite.proxy port { }; + + systemd.tmpfiles.rules = [ "d ${dataDir}" "d ${configDir}" ]; + virtualisation.oci-containers.qbittorrent = { + image = "linuxserver/qbittorrent:latest"; + extraOptions = [ "--network=container:openvpn-client" ]; + dependsOn = [ "openvpn-client" ]; + volumes = [ "${dataDir}:/downloads" "${configDir}:/config" ]; + + environment = { + WEBUI_PORT = toString port; + }; + }; + + # {{{ open-vpn + virtualisation.oci-containers.openvpn-client = { + image = "ghcr.io/wfg/openvpn-client"; + extraOptions = [ + "--network=bridge" + "--cap-add=net_admin" + "--devices=/dev/net/tun" + ]; + + volumes = [ "${vpnConfigDir}:/data/vpn" ]; + ports = [ "${port}:${port}" ]; + + environment = { + KILL_SWITCH = "on"; # Turns off internet access if the VPN connection drops + FORWARDED_PORTS = "nl-ams-59103"; + }; + }; + # }}} +}