From 0fc3c44c4e85436fbe0fee3c124e4c8d7bbdfaa4 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 19 Jul 2024 22:25:16 -0400 Subject: [PATCH] hosts: move wifi networks to wifi.nix --- hosts/common/network.nix | 42 +--------------------------------------- hosts/common/wifi.nix | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 41 deletions(-) create mode 100644 hosts/common/wifi.nix diff --git a/hosts/common/network.nix b/hosts/common/network.nix index bfa343de..a2ba7a39 100644 --- a/hosts/common/network.nix +++ b/hosts/common/network.nix @@ -4,47 +4,7 @@ ensureProfiles = { environmentFiles = [config.age.secrets.wifi.path]; - - 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"; - "FCS-WiFi2" = mkEAPWiFi "FCS-WiFi2" "$FCSIdentity" "$FCSPassword" "mschapv2"; - "javapatron" = mkOpenWiFi "javapatron"; - "Stargate-Discovery" = mkWPA2WiFi "Stargate-Discovery" "$StargateDiscoveryPSK"; - "Taproom Public WiFi" = mkOpenWiFi "Taproom Public WiFi"; - "wallace" = mkWPA2WiFi "wallace" "$wallacePSK"; - "WeWorkWiFi" = mkEAPWiFi "WeWorkWiFi" "$WeWorkWiFiIdentity" "$WeWorkWiFiPassword" "mschapv2"; - }; + profiles = import ./wifi.nix; }; }; diff --git a/hosts/common/wifi.nix b/hosts/common/wifi.nix new file mode 100644 index 00000000..724c4f5b --- /dev/null +++ b/hosts/common/wifi.nix @@ -0,0 +1,40 @@ +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"; + "FCS-WiFi2" = mkEAPWiFi "FCS-WiFi2" "$FCSIdentity" "$FCSPassword" "mschapv2"; + "javapatron" = mkOpenWiFi "javapatron"; + "Stargate-Discovery" = mkWPA2WiFi "Stargate-Discovery" "$StargateDiscoveryPSK"; + "Taproom Public WiFi" = mkOpenWiFi "Taproom Public WiFi"; + "wallace" = mkWPA2WiFi "wallace" "$wallacePSK"; + "WeWorkWiFi" = mkEAPWiFi "WeWorkWiFi" "$WeWorkWiFiIdentity" "$WeWorkWiFiPassword" "mschapv2"; +}