diff --git a/os/ccc/default.nix b/os/ccc/default.nix deleted file mode 100644 index 2c52f75..0000000 --- a/os/ccc/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ ... }: -{ - config = { - networking.wireless.networks."38C3".auth = '' - key_mgmt=WPA-EAP - eap=TTLS - identity="38C3" - password="38C3" - ca_cert="${ - builtins.fetchurl { - url = "https://letsencrypt.org/certs/isrgrootx1.pem"; - sha256 = "sha256:1la36n2f31j9s03v847ig6ny9lr875q3g7smnq33dcsmf2i5gd92"; - } - }" - altsubject_match="DNS:radius.c3noc.net" - phase2="auth=PAP" - ''; - }; -} diff --git a/os/default.nix b/os/default.nix index a9381be..8f1215c 100644 --- a/os/default.nix +++ b/os/default.nix @@ -5,7 +5,6 @@ ../common/frogarized ./battery.nix ./boot - ./ccc ./common.nix ./cuda ./desktop diff --git a/os/wireless/default.nix b/os/wireless/default.nix index 342d134..82f1d52 100644 --- a/os/wireless/default.nix +++ b/os/wireless/default.nix @@ -21,9 +21,38 @@ in temp="$(mktemp --directory --suffix="-install-wifi")" cd "$temp" + bus_get() { + sudo busctl -j get-property "fi.w1.wpa_supplicant1" "$@" + } + + network_config() { + bus_get "$1" "fi.w1.wpa_supplicant1.Network" Properties | jq '.data | keys[] as $k | "\($k)=\(.[$k] | .data)"' -r | sort + } + + # Temporarily create a new network to get defaults + default_id="$(wpa_cli add_network | tail -n1)" + network_config "/fi/w1/wpa_supplicant1/Interfaces/0/Networks/$default_id" > default.conf + wpa_cli remove_network "$default_id" + + networks_config() { + # List all interfaces + bus_get "/fi/w1/wpa_supplicant1" "fi.w1.wpa_supplicant1" Interfaces | jq '.data[]' -r | while read -r interface + do + # List all networks + bus_get "$interface" "fi.w1.wpa_supplicant1.Interface" Networks | jq '.data[]' -r | while read -r network + do + # Show configuration + echo "[$network]" + network_config "$network" > current.conf + comm -23 current.conf default.conf + rm current.conf + echo + done + done + } + # Save config for diffing later - wpa_cli save_config > /dev/null - cat <(sudo cat /run/wpa_supplicant/wpa_supplicant.conf) > old.conf + networks_config > old.conf # Export Wi-Fi config from pass ${importScript} @@ -38,11 +67,10 @@ in sudo ${applyScript} # Diff the config - wpa_cli save_config > /dev/null - cat <(sudo cat /run/wpa_supplicant/wpa_supplicant.conf) > new.conf + networks_config > new.conf diff --color=auto -U 5 old.conf new.conf - rm old.conf new.conf + rm default.conf old.conf new.conf cd / rmdir "$temp" ''; @@ -58,17 +86,6 @@ in extraConfig = '' country=NL ''; - # Public wireless networks - networks = lib.genAttrs [ - "CDWiFi" - "EurostarTrainsWiFi" - "_SNCF gare-gratuit" - "_SNCF_WIFI_INOUI" - "Wifi in de trein" - "WiFi in de trein" - "_WIFI_LYRIA" - "WIFIonICE" - ] (ssid: { }); userControlled.enable = true; # Allow some control with wpa_cli }; }; diff --git a/os/wireless/import.py b/os/wireless/import.py index 30293b0..976c317 100644 --- a/os/wireless/import.py +++ b/os/wireless/import.py @@ -59,7 +59,7 @@ for path in list_networks(): if any("EAP" in m.split("-") for m in data["key_mgmt"]): data["password"] = password - if "ssid" in data: + if "ssid" not in data: msg = f"{path}: Missing SSID" raise KeyError(msg) data.setdefault("disabled", 0)