nix/container/Download.nix

64 lines
1.4 KiB
Nix
Raw Normal View History

{
2024-11-04 04:37:29 +03:00
config,
container,
lib,
...
}: let
cfg = config.container.module.download;
in {
options.container.module.download = {
enable = lib.mkEnableOption "the bit-torrent downloader.";
address = lib.mkOption {
default = "10.1.0.12";
type = lib.types.str;
};
port = lib.mkOption {
default = 8112;
type = lib.types.int;
};
domain = lib.mkOption {
default = "download.${config.container.domain}";
type = lib.types.str;
};
storage = lib.mkOption {
default = "${config.container.storage}/download";
type = lib.types.str;
};
memLimit = lib.mkOption {
default = "4G";
type = lib.types.str;
};
};
2024-06-09 23:35:53 +03:00
2024-11-04 04:37:29 +03:00
config = lib.mkIf cfg.enable {
systemd.tmpfiles.rules = container.mkContainerDir cfg [
"data"
];
2024-06-15 17:49:19 +03:00
2024-11-04 04:37:29 +03:00
containers.download = container.mkContainer cfg {
enableTun = true;
bindMounts = {
"/var/lib/deluge/.config/deluge" = {
hostPath = "${cfg.storage}/data";
isReadOnly = false;
};
}
// container.attachMedia "download" false
;
2024-06-25 04:04:39 +03:00
2024-11-04 04:37:29 +03:00
config = { ... }: container.mkContainerConfig cfg {
services.deluge = {
enable = true;
dataDir = "/var/lib/deluge";
web.enable = true;
};
systemd.services.deluged.serviceConfig = {
MemoryLimit = cfg.memLimit;
Restart = lib.mkForce "always";
2024-11-25 00:29:13 +03:00
RuntimeMaxSec = "3h";
2024-11-04 04:37:29 +03:00
};
};
};
};
2024-06-09 23:35:53 +03:00
}