refactor: Yoink changes from upstream PR
This commit is contained in:
parent
e67c2c2a86
commit
00e827ffac
1 changed files with 82 additions and 22 deletions
|
@ -6,6 +6,28 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.services.qbittorrent-nox;
|
cfg = config.services.qbittorrent-nox;
|
||||||
|
gendeepINI = lib.generators.toINI {
|
||||||
|
mkKeyValue =
|
||||||
|
let
|
||||||
|
sep = "=";
|
||||||
|
in
|
||||||
|
k: v:
|
||||||
|
if builtins.isAttrs v then
|
||||||
|
builtins.concatStringsSep "\n"
|
||||||
|
(
|
||||||
|
lib.collect builtins.isString (
|
||||||
|
lib.mapAttrsRecursive
|
||||||
|
(
|
||||||
|
path: value:
|
||||||
|
"${lib.escape [ sep ] (builtins.oncatStringsSep "\\" ([ k ] ++ path))}${sep}${lib.generators.mkValueStringDefault { } value}"
|
||||||
|
)
|
||||||
|
v
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
lib.generators.mkKeyValueDefault { } sep k v;
|
||||||
|
};
|
||||||
|
configFile = pkgs.writeText "qBittorrent.conf" (gendeepINI cfg.serverConfig);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.qbittorrent-nox = {
|
options.services.qbittorrent-nox = {
|
||||||
|
@ -13,20 +35,6 @@ in
|
||||||
|
|
||||||
package = lib.mkPackageOption pkgs "qbittorrent-nox" { };
|
package = lib.mkPackageOption pkgs "qbittorrent-nox" { };
|
||||||
|
|
||||||
openFirewall = lib.mkEnableOption "opening both the webuiPort and torrentPort over TCP in the firewall";
|
|
||||||
|
|
||||||
webuiPort = lib.mkOption {
|
|
||||||
default = 8080;
|
|
||||||
type = lib.types.nullOr lib.types.port;
|
|
||||||
description = "the port passed to qbittorrent via `--webui-port`";
|
|
||||||
};
|
|
||||||
|
|
||||||
torrentingPort = lib.mkOption {
|
|
||||||
default = null;
|
|
||||||
type = lib.types.nullOr lib.types.port;
|
|
||||||
description = "the port passed to qbittorrent via `--torrenting-port`";
|
|
||||||
};
|
|
||||||
|
|
||||||
user = lib.mkOption {
|
user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "qbittorrent";
|
default = "qbittorrent";
|
||||||
|
@ -44,6 +52,58 @@ in
|
||||||
default = "/var/lib/qBittorrent/";
|
default = "/var/lib/qBittorrent/";
|
||||||
description = "the path passed to qbittorrent via --profile.";
|
description = "the path passed to qbittorrent via --profile.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
openFirewall = lib.mkEnableOption "opening both the webuiPort and torrentPort over TCP in the firewall";
|
||||||
|
|
||||||
|
webuiPort = lib.mkOption {
|
||||||
|
default = 8080;
|
||||||
|
type = lib.types.nullOr lib.types.port;
|
||||||
|
description = "the port passed to qbittorrent via `--webui-port`";
|
||||||
|
};
|
||||||
|
|
||||||
|
torrentingPort = lib.mkOption {
|
||||||
|
default = null;
|
||||||
|
type = lib.types.nullOr lib.types.port;
|
||||||
|
description = "the port passed to qbittorrent via `--torrenting-port`";
|
||||||
|
};
|
||||||
|
|
||||||
|
serverConfig = lib.mkOption {
|
||||||
|
type = lib.typessubmodule {
|
||||||
|
freeformType = lib.types.attrsOf (lib.types.attrsOf lib.types.anything);
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Free-form settings mapped to the `qBittorrent.conf` file in the profile.
|
||||||
|
Refer to [Explanation-of-Options-in-qBittorrent](https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent).
|
||||||
|
The Password_PBKDF2 format is oddly unique, you will likely want to use [this tool](https://codeberg.org/feathecutie/qbittorrent_password) to generate the format.
|
||||||
|
Alternatively you can run qBittorrent independently first and use its webUI to generate the format.
|
||||||
|
|
||||||
|
Optionally an alternative webUI can be easily set. VueTorrent for example:
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
Preferences = {
|
||||||
|
WebUI = {
|
||||||
|
AlternativeUIEnabled = true;
|
||||||
|
RootFolder = "''${pkgs.vuetorrent}/share/vuetorrent";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
{
|
||||||
|
LegalNotice.Accepted = true;
|
||||||
|
Preferences = {
|
||||||
|
WebUI = {
|
||||||
|
Username = "user";
|
||||||
|
Password_PBKDF2 = "generated ByteArray.";
|
||||||
|
};
|
||||||
|
General.Locale = "en";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
extraArgs = lib.mkOption {
|
extraArgs = lib.mkOption {
|
||||||
type = lib.types.listOf lib.types.str;
|
type = lib.types.listOf lib.types.str;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
@ -60,13 +120,18 @@ in
|
||||||
tmpfiles.settings = {
|
tmpfiles.settings = {
|
||||||
qbittorrent = {
|
qbittorrent = {
|
||||||
"${cfg.profileDir}/qBittorrent/"."d" = {
|
"${cfg.profileDir}/qBittorrent/"."d" = {
|
||||||
mode = "750";
|
mode = "755";
|
||||||
inherit (cfg) user group;
|
inherit (cfg) user group;
|
||||||
};
|
};
|
||||||
"${cfg.profileDir}/qBittorrent/config/"."d" = {
|
"${cfg.profileDir}/qBittorrent/config/"."d" = {
|
||||||
mode = "750";
|
mode = "755";
|
||||||
inherit (cfg) user group;
|
inherit (cfg) user group;
|
||||||
};
|
};
|
||||||
|
"${cfg.profileDir}/qBittorrent/config/qBittorrent.conf"."L+" = lib.mkIf (cfg.serverConfig != null) {
|
||||||
|
mode = "1400";
|
||||||
|
inherit (cfg) user group;
|
||||||
|
argument = "${configFile}";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
services.qbittorrent-nox = {
|
services.qbittorrent-nox = {
|
||||||
|
@ -78,12 +143,7 @@ in
|
||||||
"nss-lookup.target"
|
"nss-lookup.target"
|
||||||
];
|
];
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
restartTriggers = lib.optional (cfg.serverConfig != null) configFile;
|
||||||
# Needed for running cross-seed's hook
|
|
||||||
# /bin/sh -c "curl -XPOST http://localhost:2468/api/webhook?apikey=key --data-urlencode 'name=%N'"
|
|
||||||
path = with pkgs; [
|
|
||||||
curl
|
|
||||||
];
|
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue