nix: Fix wireless config
This commit is contained in:
parent
37a8134c23
commit
63b5e9c252
|
@ -8,7 +8,6 @@
|
|||
extraConfig = ''
|
||||
country=NL
|
||||
'';
|
||||
interfaces = ["eth0"];
|
||||
};
|
||||
environment.systemPackages = with pkgs; [ wirelesstools ];
|
||||
services.chrony.serverOption = "offline";
|
||||
|
|
|
@ -43,6 +43,9 @@ class Password:
|
|||
def val(self) -> str:
|
||||
return self.content
|
||||
|
||||
def exists(self) -> bool:
|
||||
return not not self.content
|
||||
|
||||
def key(self) -> str:
|
||||
if SEPARATE_PASSWORDS:
|
||||
return f"@{self.var()}@"
|
||||
|
@ -109,7 +112,7 @@ for path in list_networks():
|
|||
|
||||
# Helpers to prevent repetition
|
||||
suffixes = data.pop("suffixes", [""])
|
||||
data.setdefault("key_mgmt", ["WPA-PSK"] if password else ["NONE"])
|
||||
data.setdefault("key_mgmt", ["WPA-PSK"] if password.exists() else ["NONE"])
|
||||
if password:
|
||||
if any(map(lambda m: "PSK" in m.split("-"), data["key_mgmt"])):
|
||||
data["psk"] = password
|
||||
|
@ -140,7 +143,7 @@ for path in list_networks():
|
|||
if key_mgmt:
|
||||
network["authProtocols"] = key_mgmt
|
||||
if psk:
|
||||
network["pskRaw"] = psk.key()
|
||||
network["psk"] = psk.key()
|
||||
if data:
|
||||
raise NotImplementedError(f"{path}: Unhandled non-auth extra: {data}")
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue