Skip to content

VPN

WireGuard VPN configuration for confining services to a network namespace.

Available Options

This page documents 6 configuration options.

nixflix.vpn.enable

Whether to enable WireGuard VPN. Configures Wireguard in a network namespace named wg. This is independent of the host network namespace. The host network remains untouched. This means that you can run another VPN client (Wireguard, Mullvad CLI, Tailscale, etc) on the host if you wish and both VPNs will work independently.

When enabled, most Nixflix services can also be added to the VPN vpnConfinement with nixflix.<service>.vpn.enable = true;.

Any systemd service can be added to the VPN confinement manually with the following code:

systemd.services.<serviceName>.vpnConfinement = {
  enable = true;
  vpnNamespace = "wg";
};
vpnNamespaces.wg.portMappings = [
  {
    from = <servicePort>;
    to = <servicePort>;
    protocol = "tcp";
  }
];
.

Typeboolean
Default
false
Example
true
Declared inmodules/vpn.nix

nixflix.vpn.accessibleFrom

List of subnets or addresses in the default network namespace that should be able to reach services confined in the VPN namespace.

Required to access VPN-confined services (e.g. Radarr, Sonarr) from your local network. Example: ["192.168.1.0/24"].

Typelist of string
Default
[
  "192.168.1.0/24"
]
Example
[
  "192.168.1.0/24"
]
Declared inmodules/vpn.nix

nixflix.vpn.openVPNPorts

Ports to open through the VPN interface, e.g. for port forwarding provided by the VPN provider (AirVPN, IVPN, etc.).

Typelist of (submodule)
Default
[ ]
Example
[
  {
    port = 60729;
    protocol = "both";
  }
]
Declared inmodules/vpn.nix

nixflix.vpn.openVPNPorts.*.port

Port number to open through the VPN interface.

Type16 bit unsigned integer; between 0 and 65535 (both inclusive)
Declared inmodules/vpn.nix

nixflix.vpn.openVPNPorts.*.protocol

Protocol for the port.

Typeone of "tcp", "udp", "both"
Default
"tcp"
Declared inmodules/vpn.nix

nixflix.vpn.wgConfFile

Path to a wg-quick compatible WireGuard configuration file.

The file must contain at least [Interface] with Address, PrivateKey, and DNS fields, and one or more [Peer] sections with PublicKey, Endpoint, and AllowedIPs.

This file is read at service startup. Use a path to a file managed by your secrets solution (e.g. agenix, sops-nix) to keep the private key out of the Nix store.

Typeabsolute path
Example
"/etc/wireguard/airvpn.conf"
Declared inmodules/vpn.nix