networks: implement bssid support

This commit is contained in:
Primrose 2025-12-07 16:01:51 +08:00
parent b66c63601f
commit 076a4448e7
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA
3 changed files with 23 additions and 18 deletions

View file

@ -6,6 +6,7 @@ in
[ [
{ {
ssid = "~"; ssid = "~";
bssid = "de:ad:de:ad:d0:d0"; # dead dead dodo
priority = preferredPriority; priority = preferredPriority;
hasPassword = true; hasPassword = true;
} }

View file

@ -13,23 +13,27 @@ let
go = go =
networkArgs@{ networkArgs@{
ssid, ssid,
bssid ? null,
# Custom fields wrapping nixpkgs module options # Custom fields wrapping nixpkgs module options
hasPassword ? false, hasPassword ? false,
scanOnLowSignal ? false, scanOnLowSignal ? false,
randomizeMac ? false, randomizeMac ? false,
... ...
}: }:
let
uniqueKey = "${ssid}${lib.optionalString (bssid != null) bssid}";
in
{ {
${ssid} = lib.mkMerge [ ${uniqueKey} # we use a unique key here to make sure no "same ssid different bssid" networks collide in key.
=
lib.mkMerge [
(builtins.removeAttrs networkArgs [ (builtins.removeAttrs networkArgs [
# We keep ssid, because it overrides the attrset name ssid
# "ssid"
"hasPassword" "hasPassword"
"scanOnLowSignal" "scanOnLowSignal"
"randomizeMac" "randomizeMac"
]) ])
(lib.optionalAttrs hasPassword { (lib.optionalAttrs hasPassword {
pskRaw = "ext:${escapePwdKey ssid}"; pskRaw = "ext:${escapePwdKey uniqueKey}"; # this implies changing the external password key if you set a bssid!
}) })
{ {
extraConfig = '' extraConfig = ''

Binary file not shown.