feat: Port qbittorrent changes from upstream
This commit is contained in:
parent
9c9efe8a10
commit
3d3f6053dd
1 changed files with 66 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
||||||
{ config
|
{ config
|
||||||
, pkgs
|
, pkgs
|
||||||
, lib
|
, lib
|
||||||
|
, utils
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
@ -8,22 +9,21 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.qbittorrent-nox = {
|
options.services.qbittorrent-nox = {
|
||||||
enable = lib.mkEnableOption "qbittorrent, BitTorrent client.";
|
enable = lib.mkEnableOption "qbittorrent, BitTorrent client";
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "qbittorrent-nox" { };
|
package = lib.mkPackageOption pkgs "qbittorrent-nox" { };
|
||||||
|
|
||||||
openFirewall = lib.mkOption {
|
openFirewall = lib.mkEnableOption "opening both the webuiPort and torrentPort over TCP in the firewall";
|
||||||
default = false;
|
|
||||||
description = "Opens the torreting port";
|
|
||||||
};
|
|
||||||
|
|
||||||
webuiPort = lib.mkOption {
|
webuiPort = lib.mkOption {
|
||||||
type = lib.types.int;
|
default = 8080;
|
||||||
|
type = lib.types.nullOr lib.types.port;
|
||||||
description = "the port passed to qbittorrent via `--webui-port`";
|
description = "the port passed to qbittorrent via `--webui-port`";
|
||||||
};
|
};
|
||||||
|
|
||||||
torrentingPort = lib.mkOption {
|
torrentingPort = lib.mkOption {
|
||||||
type = lib.types.int;
|
default = null;
|
||||||
|
type = lib.types.nullOr lib.types.port;
|
||||||
description = "the port passed to qbittorrent via `--torrenting-port`";
|
description = "the port passed to qbittorrent via `--torrenting-port`";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,9 +38,37 @@ in
|
||||||
default = "qbittorrent";
|
default = "qbittorrent";
|
||||||
description = "Group under which qbittorrent runs.";
|
description = "Group under which qbittorrent runs.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
profileDir = lib.mkOption {
|
||||||
|
type = lib.types.path;
|
||||||
|
default = "/var/lib/qBittorrent/";
|
||||||
|
description = "the path passed to qbittorrent via --profile.";
|
||||||
|
};
|
||||||
|
extraArgs = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = ''
|
||||||
|
Extra arguments passed to qbittorrent. See `qbittorrent -h`, or the [source code](https://github.com/qbittorrent/qBittorrent/blob/master/src/app/cmdoptions.cpp), for the available arguments.
|
||||||
|
'';
|
||||||
|
example = [
|
||||||
|
"--confirm-legal-notice"
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd = {
|
systemd = {
|
||||||
|
tmpfiles.settings = {
|
||||||
|
qbittorrent = {
|
||||||
|
"${cfg.profileDir}/qBittorrent/"."d" = {
|
||||||
|
mode = "700";
|
||||||
|
inherit (cfg) user group;
|
||||||
|
};
|
||||||
|
"${cfg.profileDir}/qBittorrent/config/"."d" = {
|
||||||
|
mode = "700";
|
||||||
|
inherit (cfg) user group;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
services.qbittorrent-nox = {
|
services.qbittorrent-nox = {
|
||||||
description = "qbittorrent BitTorrent client";
|
description = "qbittorrent BitTorrent client";
|
||||||
wants = [ "network-online.target" ];
|
wants = [ "network-online.target" ];
|
||||||
|
@ -52,21 +80,35 @@ in
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
# Needed for running cross-seed's hook
|
# Needed for running cross-seed's hook
|
||||||
# /bin/sh -c "curl -XPOST http://localhost:2468/api/webhook --data-urlencode 'name=%N'"
|
# /bin/sh -c "curl -XPOST http://localhost:2468/api/webhook?apikey=key --data-urlencode 'name=%N'"
|
||||||
path = with pkgs; [
|
path = with pkgs; [
|
||||||
curl
|
curl
|
||||||
];
|
];
|
||||||
|
|
||||||
# paths: ~/.config/qBittorrent/ and ~/.local/share/qBittorrent/
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
Group = cfg.group;
|
Group = cfg.group;
|
||||||
ExecStart = "${lib.getExe cfg.package} --webui-port=${toString cfg.webuiPort} --torrenting-port=${toString cfg.torrentingPort}";
|
ExecStart = utils.escapeSystemdExecArgs (
|
||||||
|
[
|
||||||
|
(lib.getExe cfg.package)
|
||||||
|
"--profile=${cfg.profileDir}"
|
||||||
|
]
|
||||||
|
++ lib.optional (cfg.webuiPort != null) "--webui-port=${toString cfg.webuiPort}"
|
||||||
|
++ lib.optional (cfg.torrentingPort != null) "--torrenting-port=${toString cfg.torrentingPort}"
|
||||||
|
++ cfg.extraArgs
|
||||||
|
);
|
||||||
TimeoutStopSec = 1800;
|
TimeoutStopSec = 1800;
|
||||||
|
|
||||||
|
# https://github.com/qbittorrent/qBittorrent/pull/6806#discussion_r121478661
|
||||||
|
PrivateTmp = false;
|
||||||
|
|
||||||
|
PrivateNetwork = false;
|
||||||
RemoveIPC = true;
|
RemoveIPC = true;
|
||||||
NoNewPrivileges = true;
|
NoNewPrivileges = true;
|
||||||
|
PrivateDevices = true;
|
||||||
|
PrivateUsers = true;
|
||||||
|
ProtectHome = "yes";
|
||||||
ProtectProc = "invisible";
|
ProtectProc = "invisible";
|
||||||
ProcSubset = "pid";
|
ProcSubset = "pid";
|
||||||
ProtectSystem = "full";
|
ProtectSystem = "full";
|
||||||
|
@ -93,8 +135,18 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [
|
users = {
|
||||||
cfg.torrentingPort
|
users = lib.mkIf (cfg.user == "qbittorrent") {
|
||||||
];
|
qbittorrent = {
|
||||||
|
inherit (cfg) group;
|
||||||
|
isSystemUser = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
groups = lib.mkIf (cfg.group == "qbittorrent") { qbittorrent = { }; };
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall (
|
||||||
|
lib.optional (cfg.torrentingPort != null) cfg.torrentingPort
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue