nixos/services/arr-stack.nix

58 lines
1.4 KiB
Nix
Raw Normal View History

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-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";
Group = "qbittorrent";
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
chown -R qbittorrent:qbittorrent /var/lib/qbittorrent/.config
'';
};
users.users.qbittorrent = {
isSystemUser = true;
group = "qbittorrent";
home = "/var/lib/qbittorrent";
createHome = true;
};
users.groups.qbittorrent = {};
# Ensure the download directory exists with proper permissions
systemd.tmpfiles.rules = [
2026-01-21 22:49:01 +00:00
"d /mnt/storage/torrents/downloads 0775 qbittorrent qbittorrent -"
2026-01-21 22:41:48 +00:00
];
2026-01-21 22:49:01 +00:00
users.users.fred.extraGroups = [ "qbittorrent" ];
2026-01-20 21:39:16 +00:00
};
2026-01-20 21:10:47 +00:00
}