Merge pull request #305649 from rnhmjoj/pr-fix-wpa-aux

nixos/wireless: create empty config for imperative setup

authored by Michele Guerini Rocco and committed by GitHub 23fc571c b8779053

+29
+5
nixos/modules/services/networking/wpa_supplicant.nix
··· 124 124 fi 125 125 ''} 126 126 127 + # ensure wpa_supplicant.conf exists, or the daemon will fail to start 128 + ${optionalString cfg.allowAuxiliaryImperativeNetworks '' 129 + touch /etc/wpa_supplicant.conf 130 + ''} 131 + 127 132 # substitute environment variables 128 133 if [ -f "${configFile}" ]; then 129 134 ${pkgs.gawk}/bin/awk '{
+24
nixos/tests/wpa_supplicant.nix
··· 113 113 }; 114 114 }; 115 115 116 + imperative = { ... }: { 117 + imports = [ ../modules/profiles/minimal.nix ]; 118 + 119 + # add a virtual wlan interface 120 + boot.kernelModules = [ "mac80211_hwsim" ]; 121 + 122 + # wireless client 123 + networking.wireless = { 124 + enable = lib.mkOverride 0 true; 125 + userControlled.enable = true; 126 + allowAuxiliaryImperativeNetworks = true; 127 + interfaces = [ "wlan1" ]; 128 + }; 129 + }; 130 + 116 131 # Test connecting to the SAE-only hotspot using SAE 117 132 machineSae = machineWithHostapd { 118 133 networking.wireless = { ··· 184 199 status = basic.succeed("wpa_cli -i wlan1 status") 185 200 assert "Failed to connect" not in status, \ 186 201 "Failed to connect to the daemon" 202 + 203 + with subtest("Daemon can be configured imperatively"): 204 + imperative.wait_for_unit("wpa_supplicant-wlan1.service") 205 + imperative.wait_until_succeeds("wpa_cli -i wlan1 status") 206 + imperative.succeed("wpa_cli -i wlan1 add_network") 207 + imperative.succeed("wpa_cli -i wlan1 set_network 0 ssid '\"nixos-test\"'") 208 + imperative.succeed("wpa_cli -i wlan1 set_network 0 psk '\"reproducibility\"'") 209 + imperative.succeed("wpa_cli -i wlan1 save_config") 210 + imperative.succeed("grep -q nixos-test /etc/wpa_supplicant.conf") 187 211 188 212 machineSae.wait_for_unit("hostapd.service") 189 213 machineSae.copy_from_vm("/run/hostapd/wlan0.hostapd.conf")