How to make wpa_cli work in NixOS
- 04 May 2021: Post was created (diff)
Preface
More than once I’ve found myself stuck at a place without a network connection
in need of scanning for nearby access points. However, wpa_cli
does not work
out of the box when you’ve only set up your known SSID’s and pre-shared keys using
networking.wireless = {
enabled = true;
networks."my-ssid".psk = "helloworld42";
};
Enabling the control interface
The following line tends to be put at the top of the wpa_supplicant
configuration
file:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
This makes the control interface accessible by the wheel
group.
The manpage for wpa_supplicant.conf(5) states
[ctrl_interface] allow frontend (e.g., wpa_cli) to be used by all users in ‘wheel’ group
I’ve always added this line when I configured
my /etc/wpa_supplicant.conf
by hand in other operating systems, but I guess I forgot why I did it.
In NixOS this line should be added using extraConfig
:
networking.wireless.extraConfig = ''
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
'';
The resulting wpa_supplicant.conf will then look something (if not exactly) like this:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
network={
ssid="my-ssid"
psk=fec51ab9d2363e43a2f5e454aa3eab77da1aa3ae21ba71ee806e1e1f5d3cf7bd
}
If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).
Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.