diff --git a/common/fragments/bittorrent/default.nix b/common/fragments/bittorrent.nix similarity index 95% rename from common/fragments/bittorrent/default.nix rename to common/fragments/bittorrent.nix index 87a88d3..511cedc 100644 --- a/common/fragments/bittorrent/default.nix +++ b/common/fragments/bittorrent.nix @@ -77,8 +77,7 @@ }; services.nginx.enable = true; - # TODO: change when headscale updates - services.nginx.virtualHosts."watchtower.agatha.thorns.home.arpa" = { + services.nginx.virtualHosts."watchtower.thorns.home.arpa" = { locations."/flood/api" = { proxyPass = "http://127.0.0.1:3000"; proxyWebsockets = true; diff --git a/common/fragments/bittorrent/netns.nix b/common/fragments/bittorrent/netns.nix deleted file mode 100644 index 3d76b09..0000000 --- a/common/fragments/bittorrent/netns.nix +++ /dev/null @@ -1,95 +0,0 @@ -{ pkgs, ... }: -# Collectivized from https://gist.github.com/c0deaddict/53aedbb69c8cbfebfec8f4428dc03102 ☭ -let - veth = "ve-transmission"; - hostIp = "10.0.0.1/24"; - guestIp = "10.0.0.2/24"; -in -{ - # https://mth.st/blog/nixos-wireguard-netns/ - systemd.services."netns@" = { - description = "%I network namespace"; - before = [ "network.target" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - PrivateNetwork = true; - ExecStart = "${pkgs.writers.writeDash "netns-up" '' - ${pkgs.iproute}/bin/ip netns add $1 - ${pkgs.utillinux}/bin/umount /var/run/netns/$1 - ${pkgs.utillinux}/bin/mount --bind /proc/self/ns/net /var/run/netns/$1 - ''} %I"; - ExecStop = "${pkgs.iproute}/bin/ip netns del %I"; - }; - }; - - systemd.services."wireguard-ccvpn-fr" = { - bindsTo = [ "netns@transmission.service" ]; - after = [ "netns@transmission.service" ]; - }; - - networking.wireguard.interfaces.ccvpn-fr = { - ips = [ - "10.128.4.199/32" - "fd64:e20:68a3::4c7/128" - ]; - privateKeyFile = "/var/lib/secrets/ccvpn-fr-key"; - socketNamespace = "init"; - interfaceNamespace = "transmission"; - peers = [ - { - publicKey = "QFbr19X11tqUZRerZgItb25FnBsNsd7NyJvAkWTRU1U="; - # Forward all traffic via VPN. - allowedIPs = [ - "0.0.0.0/0" - "::/0" - ]; - endpoint = "fr.204vpn.net:51820"; - persistentKeepalive = 15; - } - ]; - }; - - # https://developers.redhat.com/blog/2018/10/22/introduction-to-linux-interfaces-for-virtual-networking#veth - systemd.services.${veth} = - let - ns = "transmission"; - ipHost = "${pkgs.iproute}/bin/ip"; - ipGuest = "${ipHost} netns exec ${ns} ${pkgs.iproute}/bin/ip"; - in - { - description = "Veth interface for transmission"; - bindsTo = [ "netns@${ns}.service" ]; - after = [ "netns@${ns}.service" ]; - wantedBy = [ "network.target" ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - ExecStart = pkgs.writers.writeDash "veth-up" '' - ${ipHost} link add ${veth} type veth peer name veth1 netns ${ns} - ${ipHost} addr add ${hostIp} dev ${veth} - ${ipHost} link set dev ${veth} up - ${ipGuest} addr add ${guestIp} dev veth1 - ${ipGuest} link set dev veth1 up - ''; - ExecStop = pkgs.writers.writeDash "veth-down" '' - ${ipHost} link del ${veth} - ''; - }; - }; - - networking.firewall.allowedTCPPorts = [ 9091 ]; - - services.nginx.enable = true; - # TODO: change when headscale updates - services.nginx.virtualHosts."watchtower.agatha.thorns.home.arpa" = { - locations."/transmission" = { - proxyPass = "http://10.0.0.2:9091/transmission"; - proxyWebsockets = true; - }; - locations."/bittorrent" = { - proxyPass = "http://localhost:8080"; - proxyWebsockets = true; - }; - }; -} diff --git a/common/fragments/graphical/default.nix b/common/fragments/graphical/default.nix index 8f3afc7..ab4cab6 100644 --- a/common/fragments/graphical/default.nix +++ b/common/fragments/graphical/default.nix @@ -19,7 +19,6 @@ pridefetch rink sshfs - unstable.rustmission whois wireguard-tools yt-dlp diff --git a/hosts/watchtower/configuration.nix b/hosts/watchtower/configuration.nix index 7735810..5cf0ece 100644 --- a/hosts/watchtower/configuration.nix +++ b/hosts/watchtower/configuration.nix @@ -2,7 +2,7 @@ imports = [ ./hardware-configuration.nix ../../common/home_manager/common.nix - ../../common/fragments/bittorrent + ../../common/fragments/bittorrent.nix ../../common/fragments/home-assistant.nix ../../common/fragments/sponsorblock.nix ];