Setting up wireless networking with NixOS
To enable a wireless connection with no spaces or special characters in the name that uses a pre-share key, you first need to generate the raw PSK:
wpa_passphrase exampleSSID examplePassword
network={
ssid="exampleSSID"
#psk="examplePassword"
psk=46c25aa68ccb90945621c1f1adbe93683f884f5f31c6e2d524eb6b446642762d
}
Now you can add the following stanza to your configuration.nix to enable wireless networking and this specific wireless connection:
networking.wireless = {
enable = true;
userControlled.enable = true;
networks = {
exampleSSID = {
pskRaw = "46c25aa68ccb90945621c1f1adbe93683f884f5f31c6e2d524eb6b446642762d";
};
};
};
If you had another WiFi connection that had spaces and/or special characters in the name, you would configure it like this:
networking.wireless = {
enable = true;
userControlled.enable = true;
networks = {
"example's SSID" = {
pskRaw = "46c25aa68ccb90945621c1f1adbe93683f884f5f31c6e2d524eb6b446642762d";
};
};
};
If you need to connect to a hidden network, you would do it like this:
networking.wireless = {
enable = true;
userControlled.enable = true;
networks = {
myHiddenSSID = {
hidden = true;
pskRaw = "46c25aa68ccb90945621c1f1adbe93683f884f5f31c6e2d524eb6b446642762d";
};
};
};
The final scenario that I have, is connecting to open SSIDs that have some kind of secondary method (like a login in web page) for authentication of connections:
networking.wireless = {
enable = true;
userControlled.enable = true;
networks = {
FreeWiFi = {};
};
};
Tutorial copied from mcwhirther.com.au