nix-config/modules/networking.nix
Donovan Glover ff99d22caf
chore: Replace lib.types.string with str
"string" is deprecated.
2024-04-04 07:58:32 -04:00

63 lines
1.2 KiB
Nix

{ 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";
unmanaged = [ "interface-name:ve-*" ];
};
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
];
};
};
services.resolved.llmnr = "false";
services.mullvad-vpn = mkIf mullvad {
enable = true;
enableExcludeWrapper = false;
};
};
}