Compare commits
2 Commits
3ae047f2f4
...
695bcd65c9
Author | SHA1 | Date |
---|---|---|
Adrian Gunnar Lauterer | 695bcd65c9 | |
Adrian Gunnar Lauterer | 1648415ea3 |
|
@ -2,10 +2,10 @@
|
|||
|
||||
let
|
||||
cfg = config.services.qbittorrent-nox;
|
||||
cfgPath = "/var/lib/qbittorrent/.config/qBittorrent/qBittorrent.conf";
|
||||
path = "/var/lib/qbittorrent";
|
||||
cfgPath = "${path}/.config/qBittorrent/qBittorrent.conf";
|
||||
|
||||
configurationFile = lib.writeText "${cfgPath}" ''
|
||||
configurationFile = pkgs.writeText "qbittorrent-nox.conf" ''
|
||||
[Application]
|
||||
FileLogger\Age=${toString cfg.Filelogger.age}
|
||||
FileLogger\AgeType=${toString cfg.Filelogger.ageType}
|
||||
|
@ -24,7 +24,7 @@ let
|
|||
Session\BTProtocol=${cfg.BTProtocol}
|
||||
Session\BandwidthSchedulerEnabled=${toString cfg.BandwidthSchedulerEnabled}
|
||||
Session\DefaultSavePath=${cfg.DefaultSavePath}
|
||||
Session\Encryption=${ lib.mkIf cfg.Encryption "1" "0" }
|
||||
Session\Encryption=${toString cfg.Encryption }
|
||||
Session\ExcludedFileNames=${cfg.ExcludedFileNames}
|
||||
Session\FinishedTorrentExportDirectory=${cfg.FinishedTorrentExportDirectory}
|
||||
Session\GlobalDLSpeedLimit=${toString cfg.GlobalDLSpeedLimit}
|
||||
|
@ -190,8 +190,9 @@ in
|
|||
};
|
||||
|
||||
Encryption = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
type = lib.types.int;
|
||||
default = 1;
|
||||
example = "0";
|
||||
description = "Enable encryption.";
|
||||
};
|
||||
|
||||
|
@ -440,12 +441,6 @@ in
|
|||
description = "RSS Session enable processing.";
|
||||
};
|
||||
|
||||
configFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "${cfgPath}";
|
||||
description = "Path to qbittorrent-nox configuration file.";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
@ -455,8 +450,8 @@ in
|
|||
|
||||
users.users = lib.mkIf (cfg.user == "qbittorrent") {
|
||||
qbittorrent = {
|
||||
isSystemUser = true;
|
||||
home = "/var/lib/qbittorrent";
|
||||
isNormalUser = true;
|
||||
home = path;
|
||||
group = cfg.group;
|
||||
};
|
||||
};
|
||||
|
@ -464,9 +459,11 @@ in
|
|||
qbittorrent = {};
|
||||
};
|
||||
|
||||
systemd.services."qbittorrent-nox@" ={
|
||||
systemd.services."qbittorrent-nox" ={
|
||||
serviceConfig = {
|
||||
ExecStart = "qbittorrent-nox -d --configuration=${cfg.configFile}";
|
||||
#create the configuration file from string using echo
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/cat ${configurationFile}";
|
||||
ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox --configuration=${configurationFile}";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
Restart = "on-failure";
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
{ config, lib, pkgs, options, ... }:
|
||||
let
|
||||
port = 8090;
|
||||
torrentPort = 44183;
|
||||
savePath = "/Main/Data/media/Downloads/";
|
||||
path = "/var/lib/qbittorrent";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
in
|
||||
{
|
||||
networking.firewall.allowedTCPPorts = [ port torrentPort];
|
||||
networking.firewall.allowedUDPPorts = [ port torrentPort];
|
||||
|
||||
users.users.qbittorrent = {
|
||||
isNormalUser = true; #make this a normal user to be able to make files
|
||||
home = path;
|
||||
group = "qbittorrent";
|
||||
};
|
||||
users.groups.qbittorrent = {};
|
||||
|
||||
systemd.services."qbittorrent-nox" ={
|
||||
after = [ "network.target" ];
|
||||
#environment.HOME = "/var/lib/qbittorrent";
|
||||
|
||||
serviceConfig = {
|
||||
ExecStartPre = "${pkgs.coreutils}/bin/mkdir -p ${path}";
|
||||
ExecStart = "${pkgs.qbittorrent-nox}/bin/qbittorrent-nox --webui-port=${toString port} --torrenting-port=${toString torrentPort} --save-path=${savePath}";
|
||||
User = "qbittorrent";
|
||||
Group = "qbittorrent";
|
||||
Restart = "on-failure";
|
||||
|
||||
DynamicUser = true;
|
||||
InaccessiblePaths = [ "/home" "/root" "/run" "/boot" "/etc" "/proc" "/sys" "/usr" "/lib" "/bin" "/sbin" "/srv" "/opt" ];
|
||||
|
||||
# Security options
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "full";
|
||||
ProtectKernelTunables = true;
|
||||
ProtectKernelModules = true;
|
||||
ProtectControlGroups = true;
|
||||
NoNewPrivileges = true;
|
||||
ProtectHome = true;
|
||||
PrivateDevices = true;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue