2023-12-24 22:56:50 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.pyload;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.pyload = with lib; {
|
|
|
|
enable = mkEnableOption "pyload download manager";
|
|
|
|
|
|
|
|
credentialsFile = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
example = "/run/secrets/pyload-credentials.env";
|
|
|
|
description = "pyload credentials";
|
|
|
|
};
|
|
|
|
|
|
|
|
downloadDirectory = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/data/downloads/pyload";
|
|
|
|
example = "/var/lib/pyload/download";
|
|
|
|
description = "Download directory";
|
|
|
|
};
|
|
|
|
|
|
|
|
port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 9093;
|
|
|
|
example = 8080;
|
|
|
|
description = "Internal port for webui";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.pyload = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# Listening on `localhost` leads to 502 with the reverse proxy...
|
|
|
|
listenAddress = "127.0.0.1";
|
|
|
|
|
|
|
|
inherit (cfg)
|
|
|
|
credentialsFile
|
|
|
|
downloadDirectory
|
|
|
|
port
|
|
|
|
;
|
|
|
|
|
2024-02-29 13:06:58 +01:00
|
|
|
# Use media group when downloading files
|
2023-12-24 22:56:50 +01:00
|
|
|
group = "media";
|
|
|
|
};
|
|
|
|
|
2024-02-29 13:06:58 +01:00
|
|
|
# Set-up media group
|
2023-12-24 22:56:50 +01:00
|
|
|
users.groups.media = { };
|
|
|
|
|
|
|
|
my.services.nginx.virtualHosts = {
|
|
|
|
pyload = {
|
|
|
|
inherit (cfg) port;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-11-03 14:43:16 +01:00
|
|
|
# FIXME: backup
|
|
|
|
# FIXME: persistence
|
|
|
|
|
2023-12-24 22:56:50 +01:00
|
|
|
# FIXME: fail2ban
|
|
|
|
};
|
|
|
|
}
|