From 3c31147f9d7e25fb30146cd93b680b7105848953 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Fri, 30 Jan 2026 22:20:02 +0800 Subject: [PATCH] feat: Add rqbot module and enable it --- nixos/configurations/Cape/default.nix | 6 +++ nixos/configurations/Tytonidae/default.nix | 5 ++ nixos/modules/programs/rqbit.nix | 58 ++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 nixos/modules/programs/rqbit.nix diff --git a/nixos/configurations/Cape/default.nix b/nixos/configurations/Cape/default.nix index c0c3d68..acfa8a1 100644 --- a/nixos/configurations/Cape/default.nix +++ b/nixos/configurations/Cape/default.nix @@ -40,6 +40,12 @@ enable = true; serverName = "im.youthlic.social"; }; + rqbit = { + enable = true; + unixName = "alice"; + ratelimitUpload = 0; + httpHost = "100.76.229.45"; + }; }; }; diff --git a/nixos/configurations/Tytonidae/default.nix b/nixos/configurations/Tytonidae/default.nix index 7aa3ee4..ac5fbaa 100644 --- a/nixos/configurations/Tytonidae/default.nix +++ b/nixos/configurations/Tytonidae/default.nix @@ -52,6 +52,11 @@ # emacs.enable = true; sunshine.enable = true; kdeconnect.enable = true; + rqbit = { + enable = true; + unixName = "david"; + ratelimitUpload = 10; + }; }; }; diff --git a/nixos/modules/programs/rqbit.nix b/nixos/modules/programs/rqbit.nix new file mode 100644 index 0000000..f43160a --- /dev/null +++ b/nixos/modules/programs/rqbit.nix @@ -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)} + '') + ) + )) + ]; + }; + }; + }; +}