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 |
ambroisie
left a comment
There was a problem hiding this comment.
What about a downloadDir? Is there any specific setup necessary there?
| rstudio-server = 324; | ||
| localtimed = 325; | ||
| automatic-timezoned = 326; | ||
| qbittorrent-nox = 327; |
There was a problem hiding this comment.
This shouldn't be done anymore, you should use (in order of preference):
- systemd's
DynamicUser(potentially withUserif 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.
| rstudio-server = 324; | ||
| localtimed = 325; | ||
| automatic-timezoned = 326; | ||
| qbittorrent-nox = 327; |
| in { | ||
| options = { | ||
| services = { | ||
| qbittorrent-nox = { |
There was a problem hiding this comment.
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.
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.
| 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.
Not needed, better served by systemd's service hardening options.
| PrivateTmp = "false"; | ||
| TimeoutStopSec = 1800; | ||
| }; | ||
| # preStart = preStart; |
| }) | ||
| ]; | ||
|
|
||
| environment.systemPackages = [ cfg.package ]; |
| users.users = mkIf (cfg.user == "qbittorrent") { | ||
| qbittorrent = { | ||
| group = cfg.group; | ||
| uid = config.ids.uids.qbittorrent-nox; |
There was a problem hiding this comment.
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.
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.
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.
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.
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-noxpackage 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 = relaxedsandbox = truenix-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.