2024-04-04 11:28:50 +02:00
|
|
|
{ config, lib, ... }:
|
2023-06-18 21:51:52 +02:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
let
|
|
|
|
inherit (lib) mkEnableOption mkOption mkIf;
|
2024-04-04 13:58:31 +02:00
|
|
|
inherit (lib.types) str;
|
2024-04-04 11:28:50 +02:00
|
|
|
|
|
|
|
cfg = config.modules.networking;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.modules.networking = {
|
|
|
|
mullvad = mkEnableOption "mullvad vpn";
|
2023-06-18 21:51:52 +02:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
hostName = mkOption {
|
2024-04-04 13:58:31 +02:00
|
|
|
type = str;
|
2024-04-04 11:28:50 +02:00
|
|
|
default = "nixos";
|
2023-06-18 21:51:52 +02:00
|
|
|
};
|
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
allowSRB2Port = mkEnableOption "port for srb2";
|
|
|
|
allowZolaPort = mkEnableOption "port for zola";
|
|
|
|
};
|
2023-06-18 21:51:52 +02:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
config = with cfg; {
|
|
|
|
networking = {
|
|
|
|
inherit hostName;
|
2023-12-01 05:02:50 +01:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
networkmanager = {
|
|
|
|
enable = true;
|
|
|
|
wifi.macAddress = "random";
|
|
|
|
ethernet.macAddress = "random";
|
2023-07-15 23:02:55 +02:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
unmanaged = [ "interface-name:ve-*" ];
|
|
|
|
};
|
2023-09-12 21:20:43 +02:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
useHostResolvConf = true;
|
|
|
|
|
|
|
|
resolvconf.enable = mkIf mullvad false;
|
|
|
|
|
|
|
|
nat = mkIf mullvad {
|
|
|
|
enable = true;
|
|
|
|
internalInterfaces = [ "ve-+" ];
|
|
|
|
externalInterface = "wg-mullvad";
|
|
|
|
};
|
|
|
|
|
|
|
|
firewall = {
|
|
|
|
allowedUDPPorts = mkIf allowSRB2Port [
|
|
|
|
5029
|
|
|
|
];
|
|
|
|
|
|
|
|
allowedTCPPorts = mkIf allowZolaPort [
|
|
|
|
1111
|
|
|
|
];
|
|
|
|
};
|
2023-07-15 23:02:55 +02:00
|
|
|
};
|
2024-04-03 12:19:01 +02:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
services.resolved.llmnr = "false";
|
2024-04-04 10:24:54 +02:00
|
|
|
|
2024-04-04 11:28:50 +02:00
|
|
|
services.mullvad-vpn = mkIf mullvad {
|
|
|
|
enable = true;
|
|
|
|
enableExcludeWrapper = false;
|
|
|
|
};
|
2024-04-04 10:24:54 +02:00
|
|
|
};
|
2023-06-18 21:51:52 +02:00
|
|
|
}
|