mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
43 lines
1.2 KiB
Nix
43 lines
1.2 KiB
Nix
#
|
|
# This loads the list of networks as a NixOS wpa_supplicant compatible attrset
|
|
#
|
|
# View the example config
|
|
# less $(nix-build --no-out-link -E '(import <nixpkgs> {}).wpa_supplicant')/share/doc/wpa_supplicant/wpa_supplicant.conf.example
|
|
let
|
|
sources = import ../../npins;
|
|
lib = import (sources.nixpkgs + "/lib");
|
|
|
|
# wpa_supplicant uses `strchr` to seek to the first `=`, so the only forbidden character is `=`.
|
|
escapePwdKey = lib.replaceStrings [ "=" ] [ "_" ];
|
|
|
|
go =
|
|
networkArgs@{
|
|
ssid,
|
|
# Custom fields wrapping nixpkgs module options
|
|
hasPassword ? false,
|
|
scanOnLowSignal ? false,
|
|
randomizeMac ? false,
|
|
...
|
|
}:
|
|
{
|
|
${ssid} = lib.mkMerge [
|
|
(builtins.removeAttrs networkArgs [
|
|
# We keep ssid, because it overrides the attrset name ssid
|
|
# "ssid"
|
|
"hasPassword"
|
|
"scanOnLowSignal"
|
|
"randomizeMac"
|
|
])
|
|
(lib.optionalAttrs hasPassword {
|
|
pskRaw = "ext:${escapePwdKey ssid}";
|
|
})
|
|
{
|
|
extraConfig = ''
|
|
${lib.optionalString scanOnLowSignal "bgscan=\"simple:30:-70:3600\""}
|
|
${lib.optionalString randomizeMac "mac_addr=1"}
|
|
'';
|
|
}
|
|
];
|
|
};
|
|
in
|
|
ns: lib.mkMerge (map go ns)
|