meta: Add options for networking module

Now it's possible to use the system without mullvad vpn.
This commit is contained in:
Donovan Glover 2024-04-04 05:28:50 -04:00
parent ecb2463ee7
commit 3da9c62869
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 63 additions and 35 deletions

View File

@ -57,11 +57,17 @@
home-manager.sharedModules = builtins.attrValues self.homeManagerModules; home-manager.sharedModules = builtins.attrValues self.homeManagerModules;
environment.systemPackages = builtins.attrValues self.packages.x86_64-linux; environment.systemPackages = builtins.attrValues self.packages.x86_64-linux;
modules.hardware = { modules = {
hardware = {
disableLaptopKeyboard = true; disableLaptopKeyboard = true;
lidIgnore = true; lidIgnore = true;
powerIgnore = true; powerIgnore = true;
}; };
networking = {
mullvad = true;
};
};
} }
]; ];
}; };

View File

@ -1,6 +1,27 @@
{ config, lib, ... }:
let
inherit (lib) mkEnableOption mkOption mkIf;
inherit (lib.types) string;
cfg = config.modules.networking;
in
{ {
options.modules.networking = {
mullvad = mkEnableOption "mullvad vpn";
hostName = mkOption {
type = string;
default = "nixos";
};
allowSRB2Port = mkEnableOption "port for srb2";
allowZolaPort = mkEnableOption "port for zola";
};
config = with cfg; {
networking = { networking = {
hostName = "nixos"; inherit hostName;
networkmanager = { networkmanager = {
enable = true; enable = true;
@ -12,20 +33,20 @@
useHostResolvConf = true; useHostResolvConf = true;
resolvconf.enable = false; resolvconf.enable = mkIf mullvad false;
nat = { nat = mkIf mullvad {
enable = true; enable = true;
internalInterfaces = [ "ve-+" ]; internalInterfaces = [ "ve-+" ];
externalInterface = "wg-mullvad"; externalInterface = "wg-mullvad";
}; };
firewall = { firewall = {
allowedUDPPorts = [ allowedUDPPorts = mkIf allowSRB2Port [
5029 5029
]; ];
allowedTCPPorts = [ allowedTCPPorts = mkIf allowZolaPort [
1111 1111
]; ];
}; };
@ -33,8 +54,9 @@
services.resolved.llmnr = "false"; services.resolved.llmnr = "false";
services.mullvad-vpn = { services.mullvad-vpn = mkIf mullvad {
enable = true; enable = true;
enableExcludeWrapper = false; enableExcludeWrapper = false;
}; };
};
} }