nix/container/Download.nix

69 lines
1.5 KiB
Nix
Raw Normal View History

{
container,
lib,
config,
...
}:
with lib;
let
cfg = config.container.module.download;
in
{
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
config = mkIf cfg.enable {
2024-10-14 04:51:19 +03:00
systemd.tmpfiles.rules = container.mkContainerDir cfg [ "data" ];
2024-06-14 06:06:05 +03:00
containers.download = container.mkContainer cfg {
enableTun = true;
2024-06-09 23:35:53 +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
config =
{ ... }:
container.mkContainerConfig cfg {
services.deluge = {
enable = true;
dataDir = "/var/lib/deluge";
web.enable = true;
};
2024-06-25 04:04:39 +03:00
systemd.services.deluged.serviceConfig = {
MemoryLimit = cfg.memLimit;
Restart = lib.mkForce "always";
2024-10-12 02:42:14 +03:00
RuntimeMaxSec = "6h";
};
};
};
};
2024-06-09 23:35:53 +03:00
}