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;
environment.systemPackages = builtins.attrValues self.packages.x86_64-linux;
modules.hardware = {
modules = {
hardware = {
disableLaptopKeyboard = true;
lidIgnore = 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 = {
hostName = "nixos";
inherit hostName;
networkmanager = {
enable = true;
@ -12,20 +33,20 @@
useHostResolvConf = true;
resolvconf.enable = false;
resolvconf.enable = mkIf mullvad false;
nat = {
nat = mkIf mullvad {
enable = true;
internalInterfaces = [ "ve-+" ];
externalInterface = "wg-mullvad";
};
firewall = {
allowedUDPPorts = [
allowedUDPPorts = mkIf allowSRB2Port [
5029
];
allowedTCPPorts = [
allowedTCPPorts = mkIf allowZolaPort [
1111
];
};
@ -33,8 +54,9 @@
services.resolved.llmnr = "false";
services.mullvad-vpn = {
services.mullvad-vpn = mkIf mullvad {
enable = true;
enableExcludeWrapper = false;
};
};
}