feat: Add rqbot module and enable it

This commit is contained in:
ulic-youthlic 2026-01-30 22:20:02 +08:00
parent 7f67895696
commit 3c31147f9d
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
3 changed files with 69 additions and 0 deletions

View file

@ -40,6 +40,12 @@
enable = true; enable = true;
serverName = "im.youthlic.social"; serverName = "im.youthlic.social";
}; };
rqbit = {
enable = true;
unixName = "alice";
ratelimitUpload = 0;
httpHost = "100.76.229.45";
};
}; };
}; };

View file

@ -52,6 +52,11 @@
# emacs.enable = true; # emacs.enable = true;
sunshine.enable = true; sunshine.enable = true;
kdeconnect.enable = true; kdeconnect.enable = true;
rqbit = {
enable = true;
unixName = "david";
ratelimitUpload = 10;
};
}; };
}; };

View file

@ -0,0 +1,58 @@
{
pkgs,
lib,
config,
options,
...
}: let
cfg = config.youthlic.programs.rqbit;
in {
options = {
youthlic.programs.rqbit = {
enable = lib.mkEnableOption "rqbit";
unixName = lib.mkOption {
type = lib.types.str;
};
ratelimitUpload = lib.mkOption {
type = lib.types.int;
description = ''
Limit upload to mega-bytes-per-second
'';
};
httpHost = options.services.rqbit.httpHost;
};
};
config = lib.mkIf cfg.enable {
services.rqbit = {
inherit (cfg) httpHost;
enable = true;
openFirewall = true;
httpPort = 9092;
};
users.groups.rqbit.members = [cfg.unixName];
systemd.services."rqbit" = {
serviceConfig = {
EnvironmentFile = [
(toString
(
pkgs.writeText
"rqbit-env.env"
( # env
# ''
# RQBIT_TRACKERS_FILENAME=${pkgs.trackerslist}/trackers_all.txt
# ''
''
RQBIT_TRACKERS_FILENAME=${pkgs.TrackersListCollection}/all.txt
''
+ (lib.optionalString (cfg.ratelimitUpload != 0)
# env
''
RQBIT_RATELIMIT_UPLOAD=${toString (cfg.ratelimitUpload * 1024 * 1024)}
'')
)
))
];
};
};
};
}