From d1c263b236fd530288e338f6265f426e37e0a617 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sat, 29 Jun 2024 15:20:19 -0400 Subject: [PATCH] base/networking: fix open wifi connections + add helper functions --- nixosModules/base/networking/default.nix | 113 +++++++++-------------- 1 file changed, 45 insertions(+), 68 deletions(-) diff --git a/nixosModules/base/networking/default.nix b/nixosModules/base/networking/default.nix index 50bcee46..ddea4886 100644 --- a/nixosModules/base/networking/default.nix +++ b/nixosModules/base/networking/default.nix @@ -15,83 +15,60 @@ ensureProfiles = { environmentFiles = [config.age.secrets.wifi.path]; - profiles = { - "Dustin's A54" = { + profiles = let + mkOpenWiFi = ssid: { connection = { - id = "Dustin's A54"; + id = "${ssid}"; type = "wifi"; - uuid = "fc221cbd-b6fd-44e0-8679-5998933b2fff"; + }; + + ipv4 = { + method = "auto"; + }; + + ipv6 = { + addr-gen-mode = "default"; + method = "auto"; + }; + + wifi = { + mode = "infrastructure"; + ssid = "${ssid}"; + }; + }; + + mkWPAWiFi = ssid: psk: { + connection = { + id = "${ssid}"; + type = "wifi"; + }; + + ipv4 = { + method = "auto"; + }; + + ipv6 = { + addr-gen-mode = "default"; + method = "auto"; + }; + + wifi = { + mode = "infrastructure"; + ssid = "${ssid}"; }; wifi-security = { auth-alg = "open"; key-mgmt = "wpa-psk"; - psk = "$DustinsA54PSK"; + psk = "${psk}"; }; - - wifi.ssid = "Dustin's A54"; - }; - - javapatron = { - connection = { - id = "javapatron"; - type = "wifi"; - uuid = "bb61beaa-ec07-404c-bbce-5a08ae355de7"; - }; - - wifi-security = { - auth-alg = "open"; - key-mgmt = "wpa-psk"; - }; - - wifi.ssid = "javapatron"; - }; - - "Taproom Public WiFi" = { - connection = { - id = "Taproom Public WiFi"; - type = "wifi"; - uuid = "d79280e9-4a22-4125-9583-eb7b80abfeb6"; - }; - - wifi-security = { - auth-alg = "open"; - key-mgmt = "wpa-psk"; - }; - - wifi.ssid = "Taproom Public WiFi"; - }; - - Stargate-Discovery = { - connection = { - id = "Stargate-Discovery"; - type = "wifi"; - }; - - wifi-security = { - auth-alg = "open"; - key-mgmt = "wpa-psk"; - psk = "$StargateDiscoveryPSK"; - }; - - wifi.ssid = "Stargate-Discovery"; - }; - - wallace = { - connection = { - id = "wallace"; - type = "wifi"; - uuid = "6896b13d-9717-4a8d-8a08-2a97139bf833"; - }; - - wifi-security = { - auth-alg = "open"; - key-mgmt = "wpa-psk"; - psk = "$wallacePSK"; - }; - - wifi.ssid = "wallace"; }; + in { + "Dustin's A54" = mkWPAWiFi "Dustin's A54" "$DustinsA54PSK"; + "javapatron" = mkOpenWiFi "javapatron"; + "Stargate-Discovery" = mkWPAWiFi "Stargate-Discovery" "$StargateDiscoveryPSK"; + "Taproom Public WiFi" = mkOpenWiFi "Taproom Public WiFi"; + "wallace" = mkWPAWiFi "wallace" "$wallacePSK"; WeWorkWiFi = { "802-1x" = {