nixos-config/configs/workhorse/transmission.nix

47 lines
1.2 KiB
Nix
Raw Normal View History

2019-10-24 02:20:38 +02:00
{ config, lib, ... }:
with lib;
let
2019-12-20 05:54:26 +01:00
allTincNetworks = builtins.attrNames config.module.cluster.services.tinc;
2019-10-24 02:20:38 +02:00
2019-12-20 05:54:26 +01:00
ipAddresses = flatten (mapAttrsToList
(_: data: mapAttrsToList (_: hostConfig: hostConfig.tincIp) data.hosts)
2019-10-24 02:20:38 +02:00
config.module.cluster.services.tinc);
in {
services.nginx = {
enable = true;
statusPage = true;
virtualHosts = {
"transmission.${config.networking.hostName}.private" = {
2019-12-20 05:54:26 +01:00
serverAliases = [ "torrent.${config.networking.hostName}.private" ];
2019-10-24 02:20:38 +02:00
locations."/" = {
2019-12-20 05:54:26 +01:00
proxyPass = "http://${config.networking.hostName}.private:${
toString config.services.transmission.port
}";
2019-10-24 02:20:38 +02:00
};
};
};
};
networking.firewall = {
allowedTCPPorts = [ config.services.custom.transmission.port ];
allowedUDPPorts = [ config.services.custom.transmission.port ];
};
services.custom.transmission = {
enable = true;
home = "/home/torrent";
store = "/home/torrent";
2019-12-20 05:54:26 +01:00
hosts = concatStringsSep ","
(map (name: "${config.networking.hostName}.${name}") allTincNetworks);
2019-10-24 02:20:38 +02:00
whitelist = concatStringsSep "," ipAddresses;
user = "palo";
password = lib.fileContents <secrets/transmission/password>;
};
}