From c2bca82306a324ae50577bedae0d917cda4153a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Mon, 4 Mar 2024 01:39:15 +0100 Subject: [PATCH] networking: Convert to NetworkManager --- nixos-config/default.nix | 11 +----- nixos-config/networks/personal.nix | 58 ++++++++++++++++++++++++++---- nixos-config/ren/default.nix | 38 +------------------- nixos-config/yui/networking.nix | 41 +-------------------- 4 files changed, 55 insertions(+), 93 deletions(-) diff --git a/nixos-config/default.nix b/nixos-config/default.nix index 583e23a3..77f3b51b 100644 --- a/nixos-config/default.nix +++ b/nixos-config/default.nix @@ -86,17 +86,8 @@ }; networking = { - wireless = { - enable = true; - - allowAuxiliaryImperativeNetworks = true; - userControlled = { - enable = true; - group = "network"; - }; - }; useDHCP = false; - useNetworkd = true; + networking.networkmanager.enable = true; }; time.timeZone = "Europe/Amsterdam"; diff --git a/nixos-config/networks/personal.nix b/nixos-config/networks/personal.nix index 7aa29d5b..d1602d15 100644 --- a/nixos-config/networks/personal.nix +++ b/nixos-config/networks/personal.nix @@ -1,12 +1,58 @@ {config, ...}: { - networking.wireless = { - environmentFile = config.sops.secrets.wireless-env.path; + networking.networkmanager = { + ensureProfiles.environmentFiles = [config.sops.secrets.wireless-env.path]; + + ensureProfiles.profiles = { + bond = { + connection = { + id = "bond"; + type = "bond"; + interface-name = "bond0"; + }; + + bond = { + miimon = 100; + mode = "active-backup"; + primary_reselect = "always"; + fail_over_mac = "active"; + updelay = 200; + }; + + ipv4.method = "auto"; + ipv6 = { + addr-gen-mode = "default"; + method = "auto"; + }; + }; + + ethernet = { + connection = { + id = "ethernet"; + type = "ethernet"; + + master = "bond0"; + slave-type = "bond"; + }; + }; - networks = { mikan = { - hidden = true; - authProtocols = ["WPA-PSK"]; - pskRaw = "@PSK_MIKAN@"; + connection = { + id = "mikan"; + type = "wifi"; + + master = "bond0"; + slave-type = "bond"; + }; + + wifi = { + mode = "infrastructure"; + ssid = "mikan"; + }; + + wifi-security = { + key-mgmt = "wpa-psk"; + psk = "$PSK_MIKAN"; + }; }; }; }; diff --git a/nixos-config/ren/default.nix b/nixos-config/ren/default.nix index 9bc77993..183cf59b 100644 --- a/nixos-config/ren/default.nix +++ b/nixos-config/ren/default.nix @@ -93,45 +93,9 @@ networking = { hostName = "ren"; hostId = "0d418d09"; - wireless.interfaces = ["wlp2s0"]; }; - systemd.network = { - netdevs = { - "10-bond0" = { - netdevConfig = { - Name = "bond0"; - Kind = "bond"; - }; - - bondConfig = { - Mode = "active-backup"; - PrimaryReselectPolicy = "always"; - MIIMonitorSec = "100ms"; - }; - }; - }; - - networks = { - "10-bond0" = { - matchConfig.Name = "bond0"; - networkConfig.DHCP = "yes"; - }; - - "40-enp3s0" = { - matchConfig.Name = "enp3s0"; - networkConfig = { - Bond = "bond0"; - PrimarySlave = true; - }; - }; - - "40-wlp2s0" = { - matchConfig.Name = "wlp2s0"; - networkConfig.Bond = "bond0"; - }; - }; - }; + networking.networkmanager.ensureProfiles.profiles.bond.bond.primary = "enp3s0"; theming.cursor.x-scaling = 2.0; diff --git a/nixos-config/yui/networking.nix b/nixos-config/yui/networking.nix index 50ca3e0c..08741616 100644 --- a/nixos-config/yui/networking.nix +++ b/nixos-config/yui/networking.nix @@ -1,7 +1,6 @@ { networking = { hostName = "yui"; - wireless.interfaces = ["wlp6s0"]; firewall.allowedTCPPorts = [ # Allow minecraft for when I'm running a minecraft server @@ -17,43 +16,5 @@ hosts."127.0.0.1" = ["modules-cdn.eac-prod.on.epicgames.com"]; }; - systemd.network = { - netdevs = { - "10-bond0" = { - netdevConfig = { - Name = "bond0"; - Kind = "bond"; - }; - - bondConfig = { - Mode = "active-backup"; - PrimaryReselectPolicy = "always"; - MIIMonitorSec = "100ms"; - }; - }; - }; - - networks = { - "10-bond0" = { - matchConfig.Name = "bond0"; - networkConfig.DHCP = "yes"; - linkConfig.RequiredForOnline = "yes"; - }; - - "40-eno1" = { - matchConfig.Name = "eno1"; - networkConfig = { - Bond = "bond0"; - PrimarySlave = true; - }; - linkConfig.RequiredForOnline = "no"; - }; - - "40-wlp6s0" = { - matchConfig.Name = "wlp6s0"; - networkConfig.Bond = "bond0"; - linkConfig.RequiredForOnline = "no"; - }; - }; - }; + networking.networkmanager.ensureProfiles.profiles.bond.bond.primary = "eno1"; }