nix: Fix wireless config

This commit is contained in:
Geoffrey Frogeye 2023-11-23 13:20:44 +01:00
parent 37a8134c23
commit 63b5e9c252
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
2 changed files with 5 additions and 3 deletions

View file

@ -8,7 +8,6 @@
extraConfig = ''
country=NL
'';
interfaces = ["eth0"];
};
environment.systemPackages = with pkgs; [ wirelesstools ];
services.chrony.serverOption = "offline";

View file

@ -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: