Skip to content

qbittorrent

qBittorrent stack with optional VPN routing through Gluetun:

By default, qBittorrent routes all traffic through Gluetun. To run qBittorrent without a VPN, set gluetun.enable = false.

Examples

Base

nix
{config, ...}: {
  nps.stacks.qbittorrent = {
    enable = true;

    gluetun = {
      vpnProvider = "airvpn";
      wireguardPrivateKeyFile = config.sops.secrets."gluetun/wg_pk".path;
      wireguardPresharedKeyFile = config.sops.secrets."gluetun/wg_psk".path;
      wireguardAddressesFile = config.sops.secrets."gluetun/wg_address".path;
    };
  };
}

Full

nix
{config, ...}: {
  nps.stacks.qbittorrent = {
    enable = true;

    gluetun = {
      vpnProvider = "airvpn";
      wireguardPrivateKeyFile = config.sops.secrets."gluetun/wg_pk".path;
      wireguardPresharedKeyFile = config.sops.secrets."gluetun/wg_psk".path;
      wireguardAddressesFile = config.sops.secrets."gluetun/wg_address".path;

      extraEnv = {
        FIREWALL_VPN_INPUT_PORTS.fromFile = config.sops.secrets."qbittorrent/torrenting_port".path;
      };
    };

    extraEnv = {
      TORRENTING_PORT.fromFile = config.sops.secrets."qbittorrent/torrenting_port".path;
    };

    qui = {
      enable = true;
      oidc = {
        enable = true;
        clientSecretFile = config.sops.secrets."qui/authelia/client_secret".path;
      };
    };
  };
}

Notes

Other stacks can route their containers through the Gluetun VPN by setting network = ["container:gluetun"] and dependsOnContainer = ["gluetun"] on the container. To instead expose qBittorrent/Gluetun on another stack's network, set nps.containers.gluetun.network = ["<stack>"] (or nps.containers.qbittorrent.network when Gluetun is disabled).

Stack Options

nps.stacks.qbittorrent.enable

Whether to enable qbittorrent.

Type
plaintext
boolean
Default
nix
false
Example
nix
true
Declaration

nps.stacks.qbittorrent.extraEnv

Extra environment variables to set for the container. Variables can be either set directly or sourced from a file (e.g. for secrets).

See https://docs.linuxserver.io/images/docker-qbittorrent/#environment-variables-e

Type
plaintext
attribute set of (null or boolean or signed integer or string or absolute path or (submodule))
Default
nix
{ }
Example
nix
{
  TORRENTING_PORT = "6881";
}
Declaration

nps.stacks.qbittorrent.gluetun.enable

Whether to enable Gluetun.

Type
plaintext
boolean
Default
nix
true
Example
nix
true
Declaration

nps.stacks.qbittorrent.gluetun.extraEnv

Extra environment variables to set for the container. Variables can be either set directly or sourced from a file (e.g. for secrets).

See https://github.com/qdm12/gluetun-wiki/tree/main/setup/options

Type
plaintext
attribute set of (null or boolean or signed integer or string or absolute path or (submodule))
Default
nix
{ }
Example
nix
{
  HTTPPROXY_PASSWORD = {
    fromFile = "/run/secrets/http_proxy_password";
  };
  HTTP_CONTROL_SERVER_LOG = "off";
  SERVER_NAMES = "Alderamin,Alderamin";
}
Declaration

nps.stacks.qbittorrent.gluetun.settings

Type
plaintext
TOML value
Declaration

nps.stacks.qbittorrent.gluetun.vpnProvider

The VPN provider to use with Gluetun.

Type
plaintext
string
Declaration

nps.stacks.qbittorrent.gluetun.wireguardAddressesFile

Path to the file containing the Wireguard addresses. Will be used to set the WIREGUARD_ADDRESSES environment variable.

Type
plaintext
null or absolute path
Default
nix
null
Declaration

nps.stacks.qbittorrent.gluetun.wireguardPresharedKeyFile

Path to the file containing the Wireguard pre-shared key. Will be used to set the WIREGUARD_PRESHARED_KEY environment variable.

Type
plaintext
null or absolute path
Default
nix
null
Declaration

nps.stacks.qbittorrent.gluetun.wireguardPrivateKeyFile

Path to the file containing the Wireguard private key. Will be used to set the WIREGUARD_PRIVATE_KEY environment variable.

Type
plaintext
absolute path
Declaration

nps.stacks.qbittorrent.qui.adminPasswordFile

Path to the file containing the admin password. If set, an admin user will be created automatically.

Type
plaintext
null or absolute path
Default
nix
null
Declaration

nps.stacks.qbittorrent.qui.adminUsername

Admin username to access the dashboard.

Type
plaintext
string
Default
nix
"admin"
Declaration

nps.stacks.qbittorrent.qui.enable

Whether to enable qui.

Type
plaintext
boolean
Default
nix
false
Example
nix
true
Declaration

nps.stacks.qbittorrent.qui.oidc.clientSecretFile

The file containing the client secret for the OIDC client that will be registered in Authelia.

For examples on how to generate a client secret, see

https://www.authelia.com/integration/openid-connect/frequently-asked-questions/#client-secret

Type
plaintext
string
Example
nix
config.sops.secrets."immich/authelia/client_secret".path"
Declaration

nps.stacks.qbittorrent.qui.oidc.clientSecretHash

The client secret hash. For examples on how to generate a client secret, see https://www.authelia.com/integration/openid-connect/frequently-asked-questions/#client-secret

The value can be passed in multiple ways:

  1. As a literal string
  2. As an absolute path to a file containing the hash (toFile)
  3. As an absolute oath to a file containing the client_secret, in which case the hash will be automatically computed (toHash)
  4. As null

If left unset (null), the client secret will be read from the file specified in the clientSecretFile option and hashed automatically before being passed to the Authelia container.

Type
plaintext
null or string or (submodule)
Default
nix
null
Example
nix
# Literal String:
"$pbkdf2-sha512$310000$cbOAIWbfz3vCVXIPIp6d2A$J0klwULa6TvPRCU1HAfuKua/dMKTl8gbTYJz2N73ejGUu0LUGz/y3kwmJLuKuAYGg3WQOT0q9ZzVHHUvpKpgvQ"

# Client secret hash stored in a file
{ fromFile = config.sops.secrets."immich/client_secret_hash".path; }

# Client secret stored in a file: Hash will be computed dynamically
{ toHash = config.sops.secrets."immich/client_secret".path; }

# Null (default): Hash will be computed automatically based on the clientSecretFile option
# Equivalent to { toHash = cfg.oidc.clientSecretFile; }
null
Declaration

nps.stacks.qbittorrent.qui.oidc.enable

Whether to enable OIDC login with Authelia. This will register an OIDC client in Authelia and setup the necessary configuration.

For details, see:

Type
plaintext
boolean
Default
nix
false
Declaration

nps.stacks.qbittorrent.qui.oidc.userGroup

Users of this group will be able to log in

Type
plaintext
string
Default
nix
"qui_user"
Declaration

Container Aliases

nps.stacks.qbittorrent.containers.gluetun

Alias of {option}services.podman.containers.gluetun.

Type
plaintext
submodule
Declaration

nps.stacks.qbittorrent.containers.qbittorrent

Alias of {option}services.podman.containers.qbittorrent.

Type
plaintext
submodule
Declaration

nps.stacks.qbittorrent.containers.qui

Alias of {option}services.podman.containers.qui.

Type
plaintext
submodule
Declaration