blob: 6de859882b5d1c9910ae66a078940598a440c6a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
{ pkgs, lib, config, ... }:
let
mkNetworksFromEnvironmentFile = n: builtins.listToAttrs (
map (i: {
name = "@SSID_${toString i}@";
value = {
psk = "@PSK_${toString i}@";
priority = n - i;
};
}) (lib.lists.range 1 n)
);
environmentFile = config.sops.secrets.wireless-env.path;
#networks = mkNetworksFromEnvironmentFile ((builtins.length (lib.strings.splitString "\n" (builtins.readFile environmentFile))) / 2);
networks = mkNetworksFromEnvironmentFile 10; # Number of networks listed in wireless-env
in {
options = {
wifi.enable = lib.mkEnableOption "enables wifi";
};
config = lib.mkIf config.wifi.enable {
networking.wireless = {
enable = true; # Enables wireless support via wpa_supplicant.
userControlled.enable = true;
inherit networks;
inherit environmentFile;
};
};
}
|