| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  | { config, pkgs, ... }: | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  |   delugeBase = { | 
					
						
							| 
									
										
										
										
											2025-06-01 18:35:15 -04:00
										 |  |  |     pull = "always"; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |     environment = { | 
					
						
							|  |  |  |       PUID = "600"; | 
					
						
							|  |  |  |       PGID = "100"; | 
					
						
							|  |  |  |       TZ = "America/New_York"; | 
					
						
							|  |  |  |       UMASK = "000"; | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |       DEBUG = "true"; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |       DELUGE_DAEMON_LOG_LEVEL = "debug"; | 
					
						
							|  |  |  |       DELUGE_WEB_LOG_LEVEL = "debug"; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2024-08-17 21:49:31 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |   vars = import ../vars.nix; | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |   #docker_path = vars.primary_docker; | 
					
						
							| 
									
										
										
										
											2024-08-17 21:49:31 -04:00
										 |  |  |   torr_path = vars.primary_torr; | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |   deluge_path = "${torr_path}/deluge"; | 
					
						
							|  |  |  |   delugevpn_path = "${torr_path}/delugevpn"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  |   #genSopsConfWg = file: { | 
					
						
							|  |  |  |   #  "${file}" = { | 
					
						
							|  |  |  |   #    format = "binary"; | 
					
						
							|  |  |  |   #    sopsFile = ./wg/${file}; | 
					
						
							|  |  |  |   #    path = "${delugevpn_path}/config/wireguard/configs/${file}"; | 
					
						
							|  |  |  |   #    owner = "docker-service"; | 
					
						
							|  |  |  |   #    group = "users"; | 
					
						
							|  |  |  |   #    restartUnits = [ "docker-delugeVPN.service" ]; | 
					
						
							|  |  |  |   #  }; | 
					
						
							|  |  |  |   #}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   genSopsConfOvpn = file: { | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |     "${file}" = { | 
					
						
							|  |  |  |       format = "binary"; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  |       sopsFile = ./openvpn/${file}; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:22:05 -04:00
										 |  |  |       path = "${delugevpn_path}/config/openvpn/configs/${file}"; | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |       owner = "docker-service"; | 
					
						
							|  |  |  |       group = "users"; | 
					
						
							|  |  |  |       restartUnits = [ "docker-delugeVPN.service" ]; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  | in | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-06-01 15:51:40 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |   virtualisation.oci-containers.containers = { | 
					
						
							|  |  |  |     deluge = delugeBase // { | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |       image = "binhex/arch-deluge"; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |       volumes = [ | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |         "${deluge_path}/config:/config" | 
					
						
							|  |  |  |         "${deluge_path}/data/:/data" | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |         "/etc/localtime:/etc/localtime:ro" | 
					
						
							|  |  |  |       ]; | 
					
						
							|  |  |  |       ports = [ | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |         "8084:8112" | 
					
						
							|  |  |  |         "29433:29433" | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |       ]; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     delugeVPN = delugeBase // { | 
					
						
							| 
									
										
										
										
											2025-05-05 17:17:31 -04:00
										 |  |  |       image = "binhex/arch-delugevpn:latest"; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:05:53 -04:00
										 |  |  |       capabilities = { | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  |         NET_ADMIN = true; | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2025-06-01 18:22:01 -04:00
										 |  |  |       autoRemoveOnStop = false; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |       environment = delugeBase.environment // { | 
					
						
							|  |  |  |         VPN_ENABLED = "yes"; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  |         VPN_CLIENT = "openvpn"; | 
					
						
							|  |  |  |         VPN_PROV = "protonvpn"; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |         ENABLE_PRIVOXY = "yes"; | 
					
						
							|  |  |  |         LAN_NETWORK = "192.168.0.0/16"; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:57:49 -04:00
										 |  |  |         ENABLE_STARTUP_SCRIPTS = "yes"; | 
					
						
							| 
									
										
										
										
											2025-05-05 17:17:31 -04:00
										 |  |  |         #NAME_SERVERS = "194.242.2.9"; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:51:40 -04:00
										 |  |  |         #NAME_SERVERS = "9.9.9.9"; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |         # note, delete /config/perms.txt to force a bulk permissions update | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  |       environmentFiles = [ config.sops.secrets."docker/delugevpn".path ]; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |       volumes = [ | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |         "${delugevpn_path}/config:/config" | 
					
						
							| 
									
										
										
										
											2025-05-05 17:17:31 -04:00
										 |  |  |         "${deluge_path}/data:/data" # use common torrent path yuck | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |         "/etc/localtime:/etc/localtime:ro" | 
					
						
							|  |  |  |       ]; | 
					
						
							|  |  |  |       ports = [ | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  |         "8085:8112" | 
					
						
							|  |  |  |         "8119:8118" | 
					
						
							|  |  |  |         "39275:39275" | 
					
						
							|  |  |  |         "39275:39275/udp" | 
					
						
							| 
									
										
										
										
											2025-05-05 17:17:31 -04:00
										 |  |  |         "48346:48346" | 
					
						
							|  |  |  |         "48346:48346/udp" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  |       ]; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-01 15:22:05 -04:00
										 |  |  |   systemd.services.docker-delugeVPN = { | 
					
						
							|  |  |  |     serviceConfig = { | 
					
						
							|  |  |  |       ExecStartPre = [ | 
					
						
							|  |  |  |         ( | 
					
						
							|  |  |  |           "${pkgs.bash}/bin/bash -c \"${pkgs.findutils}/bin/find ${delugevpn_path}/config/openvpn/configs " | 
					
						
							|  |  |  |           + "-type l -not -name network.ovpn " | 
					
						
							|  |  |  |           + "| ${pkgs.coreutils}/bin/shuf -n 1 " | 
					
						
							|  |  |  |           + "| ${pkgs.findutils}/bin/xargs -I {} cp -L {} ${delugevpn_path}/config/openvpn/network.ovpn &&" | 
					
						
							|  |  |  |           + "${pkgs.coreutils}/bin/chown docker-service:users ${delugevpn_path}/config/openvpn/network.ovpn &&" | 
					
						
							|  |  |  |           + "${pkgs.coreutils}/bin/chmod 440 ${delugevpn_path}/config/openvpn/network.ovpn\"" | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2025-06-01 18:29:54 -04:00
										 |  |  |         ( | 
					
						
							|  |  |  |           "${pkgs.bash}/bin/bash -c \"${pkgs.findutils}/bin/find ${delugevpn_path}/config/scripts/links " | 
					
						
							|  |  |  |           + "-type l " | 
					
						
							|  |  |  |           + "| ${pkgs.findutils}/bin/xargs -I {} cp -L {} ${delugevpn_path}/config/scripts/ \"" | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2025-06-01 15:22:05 -04:00
										 |  |  |       ]; | 
					
						
							| 
									
										
										
										
											2025-06-01 18:29:54 -04:00
										 |  |  |       ExecStopPost = [ "${pkgs.coreutils}/bin/rm ${delugevpn_path}/config/scripts/*sh" ]; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:22:05 -04:00
										 |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							| 
									
										
										
										
											2024-11-28 13:15:39 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  |   sops.secrets = (genSopsConfOvpn "se.protonvpn.udp.ovpn") // { | 
					
						
							| 
									
										
										
										
											2025-06-01 15:51:40 -04:00
										 |  |  |     "docker/delugevpn" = { | 
					
						
							|  |  |  |       owner = "docker-service"; | 
					
						
							|  |  |  |       group = "users"; | 
					
						
							|  |  |  |       restartUnits = [ "docker-delugeVPN.service" ]; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |     "docker/protonvpn-start-script" = { | 
					
						
							| 
									
										
										
										
											2025-06-01 18:29:54 -04:00
										 |  |  |       path = "${delugevpn_path}/config/scripts/links/protonvpn-start-script.sh"; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:51:40 -04:00
										 |  |  |       owner = "docker-service"; | 
					
						
							|  |  |  |       group = "users"; | 
					
						
							|  |  |  |       restartUnits = [ "docker-delugeVPN.service" ]; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2025-06-01 15:04:11 -04:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2024-08-16 12:15:42 -04:00
										 |  |  | } |