config/modules/nixos/services/vpn/default.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

2024-05-23 20:26:30 +00:00
{
lib,
config,
pkgs,
...
}:
with lib;
with lib.custom; let
cfg = config.services.vpn;
in {
options.services.vpn = with types; {
2024-05-23 21:24:09 +00:00
enable = mkBoolOpt false "Enable VPN service(s)";
2024-05-27 03:11:41 -04:00
mullvad = mkBoolOpt false "Enable Mullvad VPN Daemon";
2024-05-23 20:26:30 +00:00
};
config = mkIf cfg.enable {
2025-03-22 16:03:07 -04:00
services.mullvad-vpn = {
enable = cfg.mullvad;
package = nixos-stable.mullvad;
};
#
# # Create a specific network namespace for VPN traffic
# systemd.services.mullvad-daemon = {
# serviceConfig = {
# NetworkNamespacePath = "/run/netns/mullvad";
# };
# };
#
# # Configure transmission to use Mullvad's SOCKS5 proxy
# # Configure transmission to use the Mullvad network namespace
# systemd.services.transmission = mkIf config.services.transmission.enable {
# serviceConfig = {
# NetworkNamespacePath = "/run/netns/mullvad";
# };
# # Make sure Mullvad is running before transmission starts
# requires = ["mullvad-daemon.service"];
# after = ["mullvad-daemon.service"];
# };
services.openvpn = {
servers = {
work = {
config = ''config /home/zoey/Downloads/zachary_myers.ovpn'';
updateResolvConf = true;
};
2024-05-23 20:26:30 +00:00
};
};
systemd.services.openvpn-work.wantedBy = lib.mkForce [];
2025-03-22 16:03:07 -04:00
# # Add necessary networking tools
# environment.systemPackages = with pkgs; [
# iproute2 # for ip netns commands
# ];
#
# # Setup network namespace
# systemd.services.setup-mullvad-netns = {
# description = "Setup Mullvad Network Namespace";
# before = ["mullvad-daemon.service"];
# serviceConfig = {
# Type = "oneshot";
# RemainAfterExit = true;
# ExecStart = "${pkgs.iproute2}/bin/ip netns add mullvad";
# ExecStop = "${pkgs.iproute2}/bin/ip netns delete mullvad";
# };
# };
2024-05-23 20:26:30 +00:00
};
}