mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
vanadium: refactor network configuration
This generates the "key" used in a external password configuration, reducing the boilerplate.
This commit is contained in:
parent
8cb8166254
commit
545234254b
2 changed files with 43 additions and 34 deletions
|
|
@ -32,41 +32,52 @@
|
||||||
userControlled.enable = true;
|
userControlled.enable = true;
|
||||||
secretsFile = config.age.secrets.wpa_password.path;
|
secretsFile = config.age.secrets.wpa_password.path;
|
||||||
networks = let
|
networks = let
|
||||||
orderedByGroups = networkGroups: let
|
# The higher the more preferred
|
||||||
groupsCount = builtins.length networkGroups;
|
prio = i: lib.mapAttrs (_: conf: conf // {priority = i;});
|
||||||
withPriority =
|
|
||||||
lib.lists.imap0
|
|
||||||
(i: lib.mapAttrs (_: n: n // {priority = groupsCount - i;}))
|
|
||||||
networkGroups;
|
|
||||||
in
|
|
||||||
lib.mkMerge withPriority;
|
|
||||||
in
|
|
||||||
orderedByGroups [
|
|
||||||
{
|
|
||||||
"HiddenParadize@Earth2077".pskRaw = "ext:HOME";
|
|
||||||
"Pei’s Wifi".pskRaw = "ext:PEI";
|
|
||||||
"girlypop-net".pskRaw = "ext:GIRLYPOP";
|
|
||||||
"annapurna".pskRaw = "ext:ANNAPURNA";
|
|
||||||
|
|
||||||
"5526-1" = {
|
privatePrio = prio 10;
|
||||||
pskRaw = "ext:5526-1";
|
limitedDataPrio = prio (-10);
|
||||||
extraConfig = ''
|
|
||||||
bgscan="simple:30:-70:3600"
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
{
|
|
||||||
"A-WAY".pskRaw = "ext:A-WAY";
|
|
||||||
"CAT.jpgcafe".pskRaw = "ext:CAT.jpgcafe";
|
|
||||||
|
|
||||||
|
openNetworks = lib.flip lib.genAttrs (_: {});
|
||||||
|
pskNetworks = let
|
||||||
|
# wpa_supplicant uses `strchr` to seek to the first `=`, so the only forbidden character is `=`.
|
||||||
|
escapePwdKey = lib.replaceStrings ["="] ["_"];
|
||||||
|
in
|
||||||
|
lib.flip lib.genAttrs (name: {pskRaw = "ext:${escapePwdKey name}";});
|
||||||
|
in
|
||||||
|
lib.mkMerge [
|
||||||
|
(privatePrio (pskNetworks [
|
||||||
|
"HiddenParadize@Earth2077"
|
||||||
|
"Pei’s Wifi"
|
||||||
|
"girlypop-net"
|
||||||
|
"annapurna"
|
||||||
|
"5526-1"
|
||||||
|
|
||||||
|
"A-WAY"
|
||||||
|
"CAT.jpgcafe"
|
||||||
# TODO: Figure out how to configure networks of "same password, different ssid".
|
# TODO: Figure out how to configure networks of "same password, different ssid".
|
||||||
#
|
#
|
||||||
# In the following documentation, bssid can be used to match
|
# In the following documentation, bssid can be used to match
|
||||||
# Besides, is it possible to have duplicated SSID?
|
# Besides, is it possible to have duplicated SSID?
|
||||||
# https://man.freebsd.org/cgi/man.cgi?wpa_supplicant.conf%285%29
|
# https://man.freebsd.org/cgi/man.cgi?wpa_supplicant.conf%285%29
|
||||||
"LOUISA".pskRaw = "ext:LOUISA"; # 區公所
|
"LOUISA" # 區公所
|
||||||
"LouisaCoffee".pskRaw = "ext:LouisaCoffee"; # 七張
|
"LouisaCoffee" # 七張
|
||||||
|
]))
|
||||||
|
|
||||||
|
(limitedDataPrio (pskNetworks [
|
||||||
|
"iPhone de Léana 江"
|
||||||
|
]))
|
||||||
|
|
||||||
|
(openNetworks [
|
||||||
|
"_SNCF_WIFI_INOUI"
|
||||||
|
"_WIFI_LYRIA"
|
||||||
|
"EurostarTrainsWiFi"
|
||||||
|
"SBB-FREE"
|
||||||
|
"AOT Airport Free Wi-Fi by NT"
|
||||||
|
])
|
||||||
|
|
||||||
|
# TODO: Delete this when my account is deactivated
|
||||||
|
{
|
||||||
eduroam = {
|
eduroam = {
|
||||||
authProtocols = ["WPA-EAP"];
|
authProtocols = ["WPA-EAP"];
|
||||||
auth = ''
|
auth = ''
|
||||||
|
|
@ -82,15 +93,13 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Other per-network configuration
|
||||||
|
# bgscan has performance penalty so we don't enable it globally
|
||||||
{
|
{
|
||||||
"_SNCF_WIFI_INOUI" = {};
|
"5526-1".extraConfig = ''
|
||||||
"_WIFI_LYRIA" = {};
|
bgscan="simple:30:-70:3600"
|
||||||
"EurostarTrainsWiFi" = {};
|
'';
|
||||||
"SBB-FREE" = {};
|
|
||||||
"AOT Airport Free Wi-Fi by NT" = {};
|
|
||||||
}
|
|
||||||
{
|
|
||||||
"iPhone de Léana 江".pskRaw = "ext:PHONE";
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue