nix/container/Download.nix

60 lines
1.3 KiB
Nix
Raw Normal View History

2024-06-25 04:04:39 +03:00
{ container, lib, config, ... }: with lib; let
cfg = config.container.module.download;
2024-06-09 23:35:53 +03:00
in {
2024-06-25 04:04:39 +03:00
options = {
container.module.download = {
enable = mkEnableOption "Downloader.";
address = mkOption {
default = "10.1.0.12";
type = types.str;
};
port = mkOption {
default = 8112;
type = types.int;
};
domain = mkOption {
default = "download.${config.container.domain}";
type = types.str;
};
storage = mkOption {
default = "${config.container.storage}/download";
type = types.str;
};
memLimit = mkOption {
default = "4G";
type = types.str;
};
};
};
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
config = mkIf cfg.enable {
systemd.tmpfiles.rules = container.mkContainerDir cfg [
"data"
];
2024-06-14 06:06:05 +03:00
2024-06-25 04:04:39 +03:00
containers.download = container.mkContainer cfg {
enableTun = true;
2024-06-09 23:35:53 +03:00
2024-06-25 04:04:39 +03:00
bindMounts = {
"/var/lib/deluge/.config/deluge" = {
hostPath = "${cfg.storage}/data";
isReadOnly = false;
};
} // container.attachMedia "download" false;
2024-06-15 17:49:19 +03:00
2024-06-25 04:04:39 +03:00
config = { ... }: container.mkContainerConfig cfg {
services.deluge = {
enable = true;
dataDir = "/var/lib/deluge";
web.enable = true;
};
2024-09-16 12:01:27 +03:00
systemd.services.deluged.serviceConfig = {
MemoryLimit = cfg.memLimit;
RuntimeMaxSec = "1d";
};
2024-06-25 04:04:39 +03:00
};
2024-06-09 23:35:53 +03:00
};
};
}