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
10networking.wireless.enable = true;
11```
12
13NixOS lets you specify networks for wpa_supplicant declaratively:
14
15```nix
16networking.wireless.networks = {
17 echelon = { # SSID with no spaces or special characters
18 psk = "abcdefgh";
19 };
20 "echelon's AP" = { # SSID with spaces and/or special characters
21 psk = "ijklmnop";
22 };
23 echelon = { # Hidden SSID
24 hidden = true;
25 psk = "qrstuvwx";
26 };
27 free.wifi = {}; # Public wireless network
28};
29```
30
31Be aware that keys will be written to the nix store in plaintext! When
32no networks are set, it will default to using a configuration file at
33`/etc/wpa_supplicant.conf`. You should edit this file yourself to define
34wireless networks, WPA keys and so on (see wpa_supplicant.conf(5)).
35
36If you are using WPA2 you can generate pskRaw key using
37`wpa_passphrase`:
38
39```ShellSession
40$ wpa_passphrase ESSID PSK
41network={
42 ssid="echelon"
43 #psk="abcdefgh"
44 psk=dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435
45}
46```
47
48```nix
49networking.wireless.networks = {
50 echelon = {
51 pskRaw = "dca6d6ed41f4ab5a984c9f55f6f66d4efdc720ebf66959810f4329bb391c5435";
52 };
53};
54```
55
56or you can use it to directly generate the `wpa_supplicant.conf`:
57
58```ShellSession
59# wpa_passphrase ESSID PSK > /etc/wpa_supplicant.conf
60```
61
62After you have edited the `wpa_supplicant.conf`, you need to restart the
63wpa_supplicant service.
64
65```ShellSession
66# systemctl restart wpa_supplicant.service
67```