diff --git a/hosts/fw/configuration.nix b/hosts/fw/configuration.nix index 87c6312..4728229 100644 --- a/hosts/fw/configuration.nix +++ b/hosts/fw/configuration.nix @@ -49,7 +49,8 @@ ./modules/firefox-sync.nix ./modules/fivefilters.nix - + ./modules/pyload.nix + # home assistant ./modules/home-assistant ./modules/deconz.nix diff --git a/hosts/fw/modules/dnsmasq.nix b/hosts/fw/modules/dnsmasq.nix index 70d5ef9..f587d36 100644 --- a/hosts/fw/modules/dnsmasq.nix +++ b/hosts/fw/modules/dnsmasq.nix @@ -133,6 +133,9 @@ "/foundry-vtt.cloonar.com/${config.networkPrefix}.97.5" "/sync.cloonar.com/${config.networkPrefix}.97.5" + # multimedia + "/dl.cloonar.com/${config.networkPrefix}.97.5" + "/deconz.cloonar.multimedia/${config.networkPrefix}.97.22" "/ddl-warez.to/172.67.184.30" diff --git a/hosts/fw/modules/pyload.nix b/hosts/fw/modules/pyload.nix new file mode 100644 index 0000000..ed3be4e --- /dev/null +++ b/hosts/fw/modules/pyload.nix @@ -0,0 +1,73 @@ +{ config, pkgs, ... }: +let + cids = import ./staticids.nix; + networkPrefix = config.networkPrefix; + + user = { + isSystemUser = true; + uid = cids.uids.pyload; + group = "pyload"; + home = "/var/lib/pyload"; + createHome = true; + }; + group = { + gid = cids.gids.pyload; + }; +in +{ + users.users.pyload = user; + users.groups.pyload = group; + + # Create the multimedia directory structure on the host + systemd.tmpfiles.rules = [ + "d /var/lib/multimedia 0755 root root - -" + "d /var/lib/multimedia/downloads 0755 pyload pyload - -" + "d /var/lib/multimedia/movies 0755 pyload pyload - -" + "d /var/lib/multimedia/tv-shows 0755 pyload pyload - -" + ]; + + containers.pyload = { + autoStart = true; + ephemeral = false; + privateNetwork = true; + hostBridge = "server"; + hostAddress = "${networkPrefix}.97.1"; + localAddress = "${networkPrefix}.97.11/24"; + + bindMounts = { + "/var/lib/pyload" = { + hostPath = "/var/lib/pyload"; + isReadOnly = false; + }; + "/multimedia" = { + hostPath = "/var/lib/multimedia"; + isReadOnly = false; + }; + }; + + config = { lib, config, pkgs, ... }: { + networking = { + hostName = "pyload"; + useHostResolvConf = false; + defaultGateway = { + address = "${networkPrefix}.97.1"; + interface = "eth0"; + }; + nameservers = [ "${networkPrefix}.97.1" ]; + firewall.enable = false; + }; + + services.pyload = { + enable = true; + downloadDirectory = "/multimedia/downloads"; + listenAddress = "0.0.0.0"; + port = 8000; + }; + + users.users.pyload = user; + users.groups.pyload = group; + + system.stateVersion = "24.05"; + }; + }; +} diff --git a/hosts/fw/modules/staticids.nix b/hosts/fw/modules/staticids.nix index 498d9db..57247a5 100644 --- a/hosts/fw/modules/staticids.nix +++ b/hosts/fw/modules/staticids.nix @@ -5,6 +5,7 @@ gitea-runner = 10003; podman = 10004; foundry-vtt = 10005; + pyload = 10006; }; gids = { unbound = 10001; @@ -12,5 +13,6 @@ gitea-runner = 10003; podman = 10004; foundry-vtt = 10005; + pyload = 10006; }; } diff --git a/hosts/fw/modules/web/proxies.nix b/hosts/fw/modules/web/proxies.nix index 87878cd..0ba1533 100644 --- a/hosts/fw/modules/web/proxies.nix +++ b/hosts/fw/modules/web/proxies.nix @@ -33,4 +33,21 @@ proxyPass = "http://${config.networkPrefix}.97.10"; }; }; + services.nginx.virtualHosts."dl.cloonar.com" = { + forceSSL = true; + enableACME = true; + acmeRoot = null; + + # Restrict to internal LAN only + extraConfig = '' + allow ${config.networkPrefix}.96.0/24; + allow ${config.networkPrefix}.98.0/24; + deny all; + ''; + + locations."/" = { + proxyPass = "http://${config.networkPrefix}.97.11:8000"; + proxyWebsockets = true; + }; + }; } diff --git a/hosts/nb/users/dominik.nix b/hosts/nb/users/dominik.nix index 90035c4..cee91e4 100644 --- a/hosts/nb/users/dominik.nix +++ b/hosts/nb/users/dominik.nix @@ -228,6 +228,21 @@ in Restart = "always"; }; }; + pyload-tunnel = { + Unit = { + Description = "SSH tunnel for pyLoad Click'n'Load"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + Service = { + ExecStart = "${pkgs.openssh}/bin/ssh -N -L 9666:10.42.97.11:9666 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 root@fw.cloonar.com"; + Restart = "always"; + RestartSec = "10s"; + }; + }; }; programs.chromium = {