@@ -40,7 +40,8 @@ in {
4040 default = [];
4141 example = [ "wlan0" "wlan1" ];
4242 description = ''
43− The interfaces <command>wpa_supplicant</command> will use.
43+ The interfaces <command>wpa_supplicant</command> will use. If empty, it will
44+ automatically use all wireless interfaces.
4445 '';
4546 };
4647
@@ -219,14 +220,7 @@ in {
219220 };
220221
221222 config = mkIf cfg.enable {
222− assertions = [
223− { assertion = cfg.interfaces != [];
224− message = ''
225− No network interfaces for wpa_supplicant have been configured.
226− Please, specify at least one using networking.wireless.interfaces.
227− '';
228− }
229− ] ++ flip mapAttrsToList cfg.networks (name: cfg: {
223+ assertions = flip mapAttrsToList cfg.networks (name: cfg: {
230224 assertion = with cfg; count (x: x != null) [ psk pskRaw auth ] <= 1;
231225 message = ''options networking.wireless."${name}".{psk,pskRaw,auth} are mutually exclusive'';
232226 });
@@ -261,7 +255,20 @@ in {
261255 then echo >&2 "<3>/etc/wpa_supplicant.conf present but ignored. Generated ${configFile} is used instead."
262256 fi
263257 iface_args="-s -u -D${cfg.driver} ${configStr}"
264− args="${concatMapStringsSep " -N " (i: "-i${i} $iface_args") ifaces}"
258+ ${if ifaces == [] then ''
259+ for i in $(cd /sys/class/net && echo *); do
260+ DEVTYPE=
261+ UEVENT_PATH=/sys/class/net/$i/uevent
262+ if [ -e "$UEVENT_PATH" ]; then
263+ source "$UEVENT_PATH"
264+ if [ "$DEVTYPE" = "wlan" -o -e /sys/class/net/$i/wireless ]; then
265+ args+="''${args:+ -N} -i$i $iface_args"
266+ fi
267+ fi
268+ done
269+ '' else ''
270+ args="${concatMapStringsSep " -N " (i: "-i${i} $iface_args") ifaces}"
271+ ''}
265272 exec wpa_supplicant $args
266273 '';
267274 };