From 30f4d4f65048632048f29165cc606c8ec603871e Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sat, 6 Apr 2024 08:37:09 -0400 Subject: [PATCH] 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. --- modules/networking.nix | 62 ------------------------------------------ modules/system.nix | 51 +++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 63 deletions(-) delete mode 100644 modules/networking.nix diff --git a/modules/networking.nix b/modules/networking.nix deleted file mode 100644 index 18b2adb9..00000000 --- a/modules/networking.nix +++ /dev/null @@ -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; - }; - }; -} diff --git a/modules/system.nix b/modules/system.nix index 01752b52..56a2189f 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -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; + }; }; }