diff options
Diffstat (limited to 'modules/root/wifi.nix')
-rw-r--r-- | modules/root/wifi.nix | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/modules/root/wifi.nix b/modules/root/wifi.nix index 54f9089..6de8598 100644 --- a/modules/root/wifi.nix +++ b/modules/root/wifi.nix @@ -1,10 +1,28 @@ -{ pkgs, lib, config, ... }: { +{ 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. - networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. + networking.wireless = { + enable = true; # Enables wireless support via wpa_supplicant. + userControlled.enable = true; + inherit networks; + inherit environmentFile; + }; }; } |