-
-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create qbittorrent-nox service #279716
Create qbittorrent-nox service #279716
Conversation
Currently there is a qbittorrent-nox package, but no configurations to make it a systemd service. I placed several basic options for this service, which should be good enough to start using the service.
These are required for setting a gid and uid for the systemd unit
To be able to use it
I was able to test it on a clean install inside of a QEMU VM The thing I couldn't do is to run the review command. The whole VM seems to crash when I run: nix-shell -p nixpkgs-review --run "nixpkgs-review pr 279716" This crashes the VM even when running it without |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a downloadDir
? Is there any specific setup necessary there?
@@ -356,6 +356,7 @@ in | |||
rstudio-server = 324; | |||
localtimed = 325; | |||
automatic-timezoned = 326; | |||
qbittorrent-nox = 327; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be done anymore, you should use (in order of preference):
- systemd's
DynamicUser
(potentially withUser
if you need a named user) users.users.<name>
.
Given the usual approach for HTPC/seedbox services, using users.users
is probably the way to go.
@@ -666,6 +667,7 @@ in | |||
rstudio-server = 324; | |||
localtimed = 325; | |||
automatic-timezoned = 326; | |||
qbittorrent-nox = 327; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same note as the uid
.
in { | ||
options = { | ||
services = { | ||
qbittorrent-nox = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would instead name it qbittorent
, add a package
option, and use qbittorent-nox
as the default package.
options = { | ||
services = { | ||
qbittorrent-nox = { | ||
enable = mkEnableOption (lib.mdDoc "qbittorrent-nox daemon"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to my proposition to rename the module:
enable = mkEnableOption (lib.mdDoc "qbittorrent-nox daemon"); | |
enable = mkEnableOption (lib.mdDoc "qBittorent daemon"); |
description = lib.mdDoc '' | ||
qbittorrent-nox web UI port. | ||
''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description = lib.mdDoc '' | |
qbittorrent-nox web UI port. | |
''; | |
description = lib.mdDoc "qBittorent web UI port"'; |
systemd.services.qbittorrent-nox = { | ||
after = [ "network.target" "local-fs.target" "network-online.target" "nss-lookup.target" ]; | ||
wantedBy = [ "multi-user.target" ]; | ||
path = [ cfg.package ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, better served by systemd's service hardening options.
PrivateTmp = "false"; | ||
TimeoutStopSec = 1800; | ||
}; | ||
# preStart = preStart; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dead code.
}) | ||
]; | ||
|
||
environment.systemPackages = [ cfg.package ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
users.users = mkIf (cfg.user == "qbittorrent") { | ||
qbittorrent = { | ||
group = cfg.group; | ||
uid = config.ids.uids.qbittorrent-nox; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As explained, please refrain from adding more uid
/gid
values to NixOS.
uid = config.ids.uids.qbittorrent-nox; |
|
||
users.groups = mkIf (cfg.group == "qbittorrent") { | ||
qbittorrent = { | ||
gid = config.ids.gids.qbittorrent-nox; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same remark as for uid
.
gid = config.ids.gids.qbittorrent-nox; |
I'm also unsure whether we still need to use I would also argue that |
@@ -0,0 +1,141 @@ | |||
{ config, lib, pkgs, ... }: | |||
|
|||
with lib; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should avoid this kind of use of with to address #208242 for this module.
use inherits where you find yourself excessively reusing lib.foo
}; | ||
}; | ||
|
||
dataDir = mkOption { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is a dataDir true here for qbit, profiles seems to be the way it manages itself, a profilesdir commandline option is available.
ExecStart = '' | ||
${cfg.package}/bin/qbittorrent-nox \ | ||
--profile=${cfg.dataDir} \ | ||
--webui-port=${toString cfg.web.port} \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
neither port options should be done with the command line options, qbittorrent has a configuration file we can define these in, we know where its state will be after all
seems i should have looked harder before i started on this, see master...nu-nu-ko:nixpkgs:init-nixos-qbittorrent
I'll draft my own PR if I can get as reference for how my module can be used right now i have a working use case in my systems repo here would also appreciate your insight as another current qbit user / someone who wants a service module for it. |
@nu-nu-ko Thank you for working on those changes, and sorry I've been absent these past days. I'd be ok with you opening your PR, using that as the actual PR that introduces this service, and I can help testing it on my machine. Let me know and I'll close this PR. |
I've created #287923 with the current issues listed, I have only somewhat addressed the read write directorys and open ports issues as defaults should be filled in properly. please ensure that PR has the same goal and functionality as you do here before closing anything, thank you. |
@nu-nu-ko Your PR seems to be following my goal. I'll be doing some tests and commenting on that PR. I'll close this PR for now |
Description of changes
The
qbittorrent-nox
package already exists, which is a headless version of qbittorrent (Only accessible via web). It being a headless service makes it a good candidate for being configured viaservices.*
options, so I opened this PR for adding some basic configurations for it to run as a Systemd service.This is my first contribution to the project, so I will greatly appreciate any comments and suggestions!
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.