From 3e893d5b0cd1338c695428f43acd31b93618b913 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sat, 21 Sep 2024 12:06:01 -0400 Subject: [PATCH] common/wifi: use iwd as wifi backend --- common/wifi.nix | 71 ++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/common/wifi.nix b/common/wifi.nix index 04e09c7a..373afc15 100644 --- a/common/wifi.nix +++ b/common/wifi.nix @@ -1,35 +1,4 @@ -{config, ...}: let - mkOpenWiFi = ssid: { - connection.id = "${ssid}"; - connection.type = "wifi"; - ipv4.method = "auto"; - ipv6.addr-gen-mode = "default"; - ipv6.method = "auto"; - wifi.mode = "infrastructure"; - wifi.ssid = "${ssid}"; - }; - - mkWPA2WiFi = ssid: psk: ( - (mkOpenWiFi ssid) - // { - wifi-security.auth-alg = "open"; - wifi-security.key-mgmt = "wpa-psk"; - wifi-security.psk = "${psk}"; - } - ); - - mkEAPWiFi = ssid: identity: pass: auth: ( - (mkOpenWiFi ssid) - // { - "802-1x".eap = "peap;"; - "802-1x".identity = "${identity}"; - "802-1x".password = "${pass}"; - "802-1x".phase2-auth = "${auth}"; - wifi-security.auth-alg = "open"; - wifi-security.key-mgmt = "wpa-eap"; - } - ); -in { +{config, ...}: { age.secrets.wifi.file = ../secrets/wifi.age; networking.networkmanager = { @@ -37,7 +6,38 @@ in { ensureProfiles = { environmentFiles = [config.age.secrets.wifi.path]; - profiles = { + profiles = let + mkOpenWiFi = ssid: { + connection.id = "${ssid}"; + connection.type = "wifi"; + ipv4.method = "auto"; + ipv6.addr-gen-mode = "default"; + ipv6.method = "auto"; + wifi.mode = "infrastructure"; + wifi.ssid = "${ssid}"; + }; + + mkWPA2WiFi = ssid: psk: ( + (mkOpenWiFi ssid) + // { + wifi-security.auth-alg = "open"; + wifi-security.key-mgmt = "wpa-psk"; + wifi-security.psk = "${psk}"; + } + ); + + mkEAPWiFi = ssid: identity: pass: auth: ( + (mkOpenWiFi ssid) + // { + "802-1x".eap = "peap;"; + "802-1x".identity = "${identity}"; + "802-1x".password = "${pass}"; + "802-1x".phase2-auth = "${auth}"; + wifi-security.auth-alg = "open"; + wifi-security.key-mgmt = "wpa-eap"; + } + ); + in { "Dustin's A54" = mkWPA2WiFi "Dustin's A54" "$DustinsA54PSK"; "InmanPerkCustomer" = mkWPA2WiFi "InmanPerkCustomer" "$InmanPerkCustomerPSK"; "Muchacho Guest" = mkOpenWiFi "Muchacho Guest"; @@ -51,5 +51,10 @@ in { "wallace" = mkWPA2WiFi "wallace" "$wallacePSK"; }; }; + + wifi = { + backend = "iwd"; + powersave = true; + }; }; }