pi/validation/service/qbittorrent.nix
Katharina Heidenreich ecf10628c3 feat: try rework
2026-04-04 16:34:02 +02:00

51 lines
No EOL
1.6 KiB
Nix

let
common = import ./common.nix;
in
rec {
getQbittorrent = serviceData:
let
qbt =
if serviceData ? qbittorrent then
common.ensureAttrset "config/services.nix qbittorrent" serviceData.qbittorrent
else
throw "config/services.nix must define qbittorrent attrset.";
webPort =
if qbt ? port then
common.ensureInt "config/services.nix qbittorrent.port" qbt.port
else
throw "config/services.nix qbittorrent.port must exist.";
rootDir =
if qbt ? root_dir then
common.ensureNonEmptyString "config/services.nix qbittorrent.root_dir" qbt.root_dir
else
throw "config/services.nix qbittorrent.root_dir must exist.";
vpn =
if qbt ? vpn then
common.ensureAttrset "config/services.nix qbittorrent.vpn" qbt.vpn
else
throw "config/services.nix qbittorrent.vpn must exist.";
usernameFile =
if vpn ? username_file then
common.ensureNonEmptyString "config/services.nix qbittorrent.vpn.username_file" vpn.username_file
else
throw "config/services.nix qbittorrent.vpn.username_file must exist.";
passwordFile =
if vpn ? password_file then
common.ensureNonEmptyString "config/services.nix qbittorrent.vpn.password_file" vpn.password_file
else
throw "config/services.nix qbittorrent.vpn.password_file must exist.";
in
{
port = webPort;
root_dir = rootDir;
vpn = {
username_file = usernameFile;
password_file = passwordFile;
};
};
}