meta: Merge networking with system

This makes it easier to ensure that the system has our network settings
such as random mac addresses. This makes sense since networking in
general is related to the system.
This commit is contained in:
Donovan Glover 2024-04-06 08:37:09 -04:00
parent 8464d87cc9
commit 30f4d4f650
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
2 changed files with 50 additions and 63 deletions

View File

@ -1,62 +0,0 @@
{ 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;
};
};
}

View File

@ -4,7 +4,7 @@ let
inherit (lib) mkOption mkEnableOption mkIf;
inherit (lib.types) nullOr str listOf;
inherit (pkgs.nixVersions) nix_2_19;
inherit (cfg) username iHaveLotsOfRam hashedPassword;
inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowZolaPort;
inherit (builtins) attrValues;
cfg = config.modules.system;
@ -46,6 +46,16 @@ in
};
iHaveLotsOfRam = mkEnableOption "tmpfs on /tmp";
hostName = mkOption {
type = str;
default = "nixos";
};
mullvad = mkEnableOption "mullvad vpn";
allowSRB2Port = mkEnableOption "port for srb2";
allowZolaPort = mkEnableOption "port for zola";
};
config = {
@ -158,5 +168,44 @@ in
boot.enableContainers = false;
};
networking = {
inherit (cfg) 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;
};
};
}