Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,7 @@
./services/torrent/opentracker.nix
./services/torrent/peerflix.nix
./services/torrent/qbittorrent.nix
./services/torrent/qui.nix
./services/torrent/rtorrent.nix
./services/torrent/torrentstream.nix
./services/torrent/transmission.nix
Expand Down
112 changes: 112 additions & 0 deletions nixos/modules/services/torrent/qui.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.qui;
format = pkgs.formats.toml { };
configFile = format.generate "config.toml" cfg.settings;
in
{
options = {
services.qui = {
enable = lib.mkEnableOption "Qui, A fast, single-binary qBittorrent web UI";

package = lib.mkPackageOption pkgs "qui" { };

openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open ports in the firewall for the qui web interface.";
};
sessionSecretPath = lib.mkOption {
type = lib.types.nullOr lib.types.str;
description = "Path to file containing secret";
default = null;
};

settings =
with lib;
mkOption {
type = types.submodule {
freeformType = format.type;

options = {
host = mkOption {
type = types.nullOr types.str;
description = "Address to bind";
default = "localhost";
};
port = mkOption {
type = types.nullOr types.int;
description = "Port to bind";
default = 7476;
};
dataDir = mkOption {
type = types.nullOr types.path;
description = "The directory where data is stored";
default = "/var/lib/qui";
};
};
};
default = { };
description = "Qui configuration, see <https://getqui.com/docs/intro> for reference.";
};

user = lib.mkOption {
type = lib.types.str;
default = "qui";
description = "User account under which qui runs.";
};

group = lib.mkOption {
type = lib.types.str;
default = "qui";
description = "Group under which qui runs.";
};
};
};

config = lib.mkIf cfg.enable {
systemd.services.qui = {
description = "qui";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
environment = {
QUI__SESSION_SECRET_FILE = cfg.sessionSecretPath;
};

serviceConfig = {
Type = "simple";
User = cfg.user;
Group = cfg.group;
StateDirectory = "qui";
ExecStart = "${cfg.package}/bin/qui serve --config-dir ${configFile}";
Restart = "on-failure";
NoNewPrivileges = true;
PrivateTmp = true;
ProtectHome = true;
ProtectSystem = "full";
ReadWritePaths = [ "/var/lib/qui" ];
};
};

networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ cfg.settings.port ];
};

users.users = lib.mkIf (cfg.user == "qui") {
qui = {
group = cfg.group;
home = cfg.settings.dataDir;
isSystemUser = true;
};
};

users.groups = lib.mkIf (cfg.group == "qui") {
qui = { };
};
};
}
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1332,6 +1332,7 @@ in
qtile = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./qtile/default.nix;
qtile-extras = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./qtile-extras/default.nix;
quake3 = runTest ./quake3.nix;
qui = runTest ./qui.nix;
quicktun = runTest ./quicktun.nix;
quickwit = runTest ./quickwit.nix;
rabbitmq = runTest ./rabbitmq.nix;
Expand Down
18 changes: 18 additions & 0 deletions nixos/tests/qui.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ lib, ... }:

{
name = "qui";
meta.maintainers = with lib.maintainers; [ tcheronneau ];

nodes.machine =
{ pkgs, ... }:
{
services.qui.enable = true;
};

testScript = ''
machine.wait_for_unit("qui.service")
machine.wait_for_open_port(7476)
machine.succeed("curl --fail http://localhost:7476/")
'';
}
Loading