2026-01-22 09:39:13 +00:00
|
|
|
#qbittorrent-nox.nix
|
2026-01-20 21:10:47 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
{
|
|
|
|
|
config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") {
|
2026-01-21 22:37:12 +00:00
|
|
|
environment.systemPackages = with pkgs; [
|
2026-01-21 22:34:37 +00:00
|
|
|
qbittorrent-nox
|
|
|
|
|
];
|
2026-01-22 09:39:13 +00:00
|
|
|
|
|
|
|
|
# Create qbittorrent user with media group
|
|
|
|
|
users.users.qbittorrent = {
|
|
|
|
|
isSystemUser = true;
|
|
|
|
|
group = "media"; # Changed to media group for sharing
|
|
|
|
|
extraGroups = [ "media" ];
|
|
|
|
|
home = "/var/lib/qbittorrent";
|
|
|
|
|
createHome = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Create media group (shared with sonarr)
|
|
|
|
|
users.groups.media = {
|
|
|
|
|
gid = 3000;
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-21 22:41:48 +00:00
|
|
|
systemd.services.qbittorrent-nox = {
|
|
|
|
|
description = "qBittorrent-nox service";
|
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "simple";
|
|
|
|
|
User = "qbittorrent";
|
2026-01-22 09:39:13 +00:00
|
|
|
Group = "media"; # Changed to media
|
2026-01-21 22:41:48 +00:00
|
|
|
ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox";
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
|
2026-01-21 22:49:01 +00:00
|
|
|
# Security hardening
|
2026-01-21 22:41:48 +00:00
|
|
|
NoNewPrivileges = true;
|
|
|
|
|
PrivateTmp = true;
|
|
|
|
|
ProtectSystem = "strict";
|
2026-01-21 22:49:01 +00:00
|
|
|
ProtectHome = true;
|
2026-01-21 22:41:48 +00:00
|
|
|
ReadWritePaths = [
|
|
|
|
|
"/var/lib/qbittorrent"
|
2026-01-21 22:49:01 +00:00
|
|
|
"/mnt/storage/torrents"
|
2026-01-21 22:41:48 +00:00
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
preStart = ''
|
|
|
|
|
mkdir -p /var/lib/qbittorrent/.config/qBittorrent
|
|
|
|
|
cat > /var/lib/qbittorrent/.config/qBittorrent/qBittorrent.conf << EOF
|
|
|
|
|
[Preferences]
|
2026-01-21 22:49:01 +00:00
|
|
|
Downloads\SavePath=/mnt/storage/torrents/downloads
|
2026-01-21 22:41:48 +00:00
|
|
|
EOF
|
2026-01-22 09:39:13 +00:00
|
|
|
chown -R qbittorrent:media /var/lib/qbittorrent/.config
|
2026-01-21 22:41:48 +00:00
|
|
|
'';
|
|
|
|
|
};
|
2026-01-22 09:39:13 +00:00
|
|
|
|
2026-01-21 22:41:48 +00:00
|
|
|
# Ensure the download directory exists with proper permissions
|
|
|
|
|
systemd.tmpfiles.rules = [
|
2026-01-22 09:39:13 +00:00
|
|
|
"d /mnt/storage/torrents/downloads 0775 qbittorrent media -"
|
2026-01-21 22:41:48 +00:00
|
|
|
];
|
2026-01-21 22:49:01 +00:00
|
|
|
|
2026-01-22 09:39:13 +00:00
|
|
|
users.users.fred.extraGroups = [ "media" ]; # Changed to media group
|
2026-01-20 21:39:16 +00:00
|
|
|
};
|
2026-01-20 21:10:47 +00:00
|
|
|
}
|