wifi: Fix installation
This commit is contained in:
parent
8179433c41
commit
ea9a75d495
4 changed files with 34 additions and 37 deletions
|
@ -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"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@
|
||||||
../common/frogarized
|
../common/frogarized
|
||||||
./battery.nix
|
./battery.nix
|
||||||
./boot
|
./boot
|
||||||
./ccc
|
|
||||||
./common.nix
|
./common.nix
|
||||||
./cuda
|
./cuda
|
||||||
./desktop
|
./desktop
|
||||||
|
|
|
@ -21,9 +21,38 @@ in
|
||||||
temp="$(mktemp --directory --suffix="-install-wifi")"
|
temp="$(mktemp --directory --suffix="-install-wifi")"
|
||||||
cd "$temp"
|
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
|
# Save config for diffing later
|
||||||
wpa_cli save_config > /dev/null
|
networks_config > old.conf
|
||||||
cat <(sudo cat /run/wpa_supplicant/wpa_supplicant.conf) > old.conf
|
|
||||||
|
|
||||||
# Export Wi-Fi config from pass
|
# Export Wi-Fi config from pass
|
||||||
${importScript}
|
${importScript}
|
||||||
|
@ -38,11 +67,10 @@ in
|
||||||
sudo ${applyScript}
|
sudo ${applyScript}
|
||||||
|
|
||||||
# Diff the config
|
# Diff the config
|
||||||
wpa_cli save_config > /dev/null
|
networks_config > new.conf
|
||||||
cat <(sudo cat /run/wpa_supplicant/wpa_supplicant.conf) > new.conf
|
|
||||||
diff --color=auto -U 5 old.conf new.conf
|
diff --color=auto -U 5 old.conf new.conf
|
||||||
|
|
||||||
rm old.conf new.conf
|
rm default.conf old.conf new.conf
|
||||||
cd /
|
cd /
|
||||||
rmdir "$temp"
|
rmdir "$temp"
|
||||||
'';
|
'';
|
||||||
|
@ -58,17 +86,6 @@ in
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
country=NL
|
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
|
userControlled.enable = true; # Allow some control with wpa_cli
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -59,7 +59,7 @@ for path in list_networks():
|
||||||
if any("EAP" in m.split("-") for m in data["key_mgmt"]):
|
if any("EAP" in m.split("-") for m in data["key_mgmt"]):
|
||||||
data["password"] = password
|
data["password"] = password
|
||||||
|
|
||||||
if "ssid" in data:
|
if "ssid" not in data:
|
||||||
msg = f"{path}: Missing SSID"
|
msg = f"{path}: Missing SSID"
|
||||||
raise KeyError(msg)
|
raise KeyError(msg)
|
||||||
data.setdefault("disabled", 0)
|
data.setdefault("disabled", 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue