1
0
Fork 0
nix-configuration/modules/services/deluge.nix

59 lines
1.3 KiB
Nix
Raw Normal View History

2024-09-08 23:47:53 -04:00
{
config,
lib,
pkgs,
...
}:
2024-08-26 12:54:38 -04:00
let
cfg = config.aux.system.services.deluge;
in
{
options = {
aux.system.services.deluge = {
enable = lib.mkEnableOption "Enables Deluge.";
home = lib.mkOption {
2024-09-07 13:44:14 -04:00
default = "/var/lib/deluge";
2024-08-26 12:54:38 -04:00
type = lib.types.str;
description = "Where to store Deluge's files";
};
url = lib.mkOption {
default = "";
type = lib.types.str;
description = "The complete URL where Deluge is hosted.";
example = "https://deluge.example.com";
};
};
};
config = lib.mkIf cfg.enable {
services = {
nginx.virtualHosts."${cfg.url}" = {
2024-09-08 23:47:53 -04:00
useACMEHost = pkgs.util.getDomainFromURL cfg.url;
2024-08-26 12:54:38 -04:00
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8112";
extraConfig = ''
proxy_set_header X-Deluge-Base "/";
add_header X-Frame-Options SAMEORIGIN;
'';
};
};
deluge = {
enable = true;
dataDir = cfg.home;
web = {
enable = true;
openFirewall = false; # Not needed since we're using a reverse proxy
};
};
};
2024-09-07 13:44:14 -04:00
systemd.services = {
deluge.unitConfig.RequiresMountsFor = cfg.home;
nginx.wants = [ config.systemd.services.deluge.name ];
};
2024-08-26 12:54:38 -04:00
};
}