nix-config/modules/networking.nix

63 lines
1.2 KiB
Nix
Raw Normal View History

{ config, lib, ... }:
let
inherit (lib) mkEnableOption mkOption mkIf;
inherit (lib.types) str;
cfg = config.modules.networking;
in
{
options.modules.networking = {
mullvad = mkEnableOption "mullvad vpn";
hostName = mkOption {
type = str;
default = "nixos";
};
allowSRB2Port = mkEnableOption "port for srb2";
allowZolaPort = mkEnableOption "port for zola";
};
config = with cfg; {
networking = {
inherit hostName;
networkmanager = {
enable = true;
wifi.macAddress = "random";
ethernet.macAddress = "random";
2023-07-15 23:02:55 +02:00
unmanaged = [ "interface-name:ve-*" ];
};
2023-09-12 21:20:43 +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
};
services.resolved.llmnr = "false";
services.mullvad-vpn = mkIf mullvad {
enable = true;
enableExcludeWrapper = false;
};
};
}