1# Wireless Networks {#sec-wireless}
2
3For a desktop installation using NetworkManager (e.g., GNOME), you just
4have to make sure the user is in the `networkmanager` group and you can
5skip the rest of this section on wireless networks.
6
7NixOS will start wpa_supplicant for you if you enable this setting:
8
9```nix
10{
11 networking.wireless.enable = true;
12}
13```
14
15NixOS lets you specify networks for wpa_supplicant declaratively:
16
17```nix
18{
19 networking.wireless.networks = {
20 echelon = { # SSID with no spaces or special characters
21 psk = "abcdefgh";
22 };
23 "echelon's AP" = { # SSID with spaces and/or special characters
24 psk = "ijklmnop";
25 };
26 echelon = { # Hidden SSID
27 hidden = true;
28 psk = "qrstuvwx";
29 };
30 free.wifi = {}; # Public wireless network
31 };
32}
33```
34
35Be aware that keys will be written to the nix store in plaintext! When
36no networks are set, it will default to using a configuration file at
37`/etc/wpa_supplicant.conf`. You should edit this file yourself to define
38wireless networks, WPA keys and so on (see wpa_supplicant.conf(5)).
39
40If you are using WPA2 you can generate pskRaw key using
41`wpa_passphrase`:
42
43```ShellSession
44$ wpa_passphrase ESSID PSK
45network={
46 ssid="echelon"
47 #psk="abcdefgh"
48 psk=dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435
49}
50```
51
52```nix
53{
54 networking.wireless.networks = {
55 echelon = {
56 pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435";
57 };
58 };
59}
60```
61
62or you can use it to directly generate the `wpa_supplicant.conf`:
63
64```ShellSession
65# wpa_passphrase ESSID PSK > /etc/wpa_supplicant.conf
66```
67
68After you have edited the `wpa_supplicant.conf`, you need to restart the
69wpa_supplicant service.
70
71```ShellSession
72# systemctl restart wpa_supplicant.service
73```