mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
tree-wide: deduplicate network compat script
This commit is contained in:
parent
5447573e69
commit
432efd430c
5 changed files with 43 additions and 69 deletions
37
nix/networks/wpa_supplicant-compat.nix
Normal file
37
nix/networks/wpa_supplicant-compat.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# This loads the list of networks as a NixOS wpa_supplicant compatible attrset
|
||||
#
|
||||
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 ["ssid" "hasPassword" "scanOnLowSignal" "randomizeMac"])
|
||||
(lib.optionalAttrs hasPassword {
|
||||
pskRaw = "ext:${escapePwdKey ssid}";
|
||||
})
|
||||
(lib.optionalAttrs scanOnLowSignal {
|
||||
extraConfig = ''
|
||||
bgscan="simple:30:-70:3600"
|
||||
'';
|
||||
})
|
||||
(lib.optionalAttrs randomizeMac {
|
||||
extraConfig = ''
|
||||
mac_addr=1
|
||||
'';
|
||||
})
|
||||
];
|
||||
};
|
||||
in
|
||||
ns: lib.mkMerge (map go ns)
|
||||
Loading…
Add table
Add a link
Reference in a new issue