dotfiles/nixos/services/torrent-wg.nix

32 lines
1.1 KiB
Nix
Raw Normal View History

2021-05-29 18:05:31 +02:00
{ pkgs, lib, config, ... }:
let cfg = config.services.yorick.torrent-vpn;
in {
2020-05-23 13:01:10 +02:00
options.services.yorick.torrent-vpn = with lib; {
enable = mkEnableOption "torrent-vpn";
name = mkOption { type = types.str; };
namespace = mkOption { type = types.str; };
};
2022-10-04 10:39:49 +02:00
config = lib.mkIf cfg.enable {
2022-05-18 15:57:58 +02:00
age.secrets.wg-torrent.file = ../../secrets/wg.${cfg.name}.age;
2020-05-23 13:01:10 +02:00
networking.wireguard.interfaces.${cfg.name} = {
2023-07-03 15:02:42 +02:00
ips = [ "10.0.34.127/32" "2a0e:1c80:1337:1:10:0:34:127/128" ];
2022-05-18 15:57:58 +02:00
privateKeyFile = config.age.secrets.wg-torrent.path;
2020-05-23 13:01:10 +02:00
peers = [{
2023-07-03 15:02:42 +02:00
publicKey = "W+LE+uFRyMRdYFCf7Jw0OPERNd1bcIm0gTKf/traIUk=";
2021-05-29 18:05:31 +02:00
allowedIPs = [ "0.0.0.0/0" "::0/0" ];
2023-07-03 15:02:42 +02:00
endpoint = "nl-ams.azirevpn.net:51820";
2020-05-23 13:01:10 +02:00
}];
interfaceNamespace = cfg.namespace;
2021-01-03 16:39:47 +01:00
preSetup = ''
2022-10-04 10:15:29 +02:00
${pkgs.iproute2}/bin/ip netns add "${cfg.namespace}" || true
2020-05-23 13:01:10 +02:00
'';
};
environment.etc."netns/torrent/resolv.conf".text = ''
2023-07-03 15:02:42 +02:00
nameserver 91.231.153.2
nameserver 192.211.0.2
nameserver 2a0e:1c80:1337:1:10:0:0:1
2020-05-23 13:01:10 +02:00
'';
};
}
# todo: presets