From 78a9369953d92c82d0e8e4e2b21498d8b1ccb01c Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Mon, 14 Apr 2025 00:16:58 +0200 Subject: [PATCH] initial attempt to add declaritive qbittorrent config --- modules/system/common/qbittorrent.nix | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/modules/system/common/qbittorrent.nix b/modules/system/common/qbittorrent.nix index 45cc2dc..4176165 100644 --- a/modules/system/common/qbittorrent.nix +++ b/modules/system/common/qbittorrent.nix @@ -61,11 +61,42 @@ in }; }; - config = mkIf cfg.enable { + config = mkIf cfg.enable (let + configFile = pkgs.writeText "qBittorrent.conf" '' + [BitTorrent] + Session\Port=53271 + Session\SSL\Port=45846 + Session\QueueingSystemEnabled=false + Session\MaxUploads=-1 + Session\MaxUploadsPerTorrent=-1 + + [Meta] + MigrationVersion=8 + + [Network] + Cookies=@Invalid() + + [Preferences] + WebUI\Port=5000 + WebUI\Username=admin + WebUI\Password_PBKDF2="@ByteArray(Clgb2+ZyS3PDRVqtYpj0Ow==:kjN301CJife6g5ou8N2mk6ydQWPQIGgrTAWg5ByWCqAv0jDLphR/IaVQ1tu9KtA+il1udi48xSXZ3AUpjK/fRw==)" + + [RSS] + AutoDownloader\DownloadRepacks=true + AutoDownloader\SmartEpisodeFilter=s(\\d+)e(\\d+), (\\d+)x(\\d+), "(\\d{4}[.\\-]\\d{1,2}[.\\-]\\d{1,2})", "(\\d{1,2}[.\\-]\\d{1,2}[.\\-]\\d{4})" + ''; + in { networking.firewall = mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; }; + systemd.tmpfiles.rules = [ + # https://www.mankier.com/5/tmpfiles.d + "d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -" + "d '${cfg.dataDir}/__config' 0700 ${cfg.user} ${cfg.group} - -" + "L+ '${cfg.dataDir}/__config/qBittorrent.conf' - - - - ${configFile}" + ]; + systemd.services.qbittorrent = { description = "qBittorrent-nox service"; documentation = [ "man:qbittorrent-nox(1)" ]; @@ -109,5 +140,5 @@ in users.groups = mkIf (cfg.group == "qbittorrent") { qbittorrent = { gid = GID; }; }; - }; + }); }