Easily configure a Wifi hotspot on NixOS

Using the linux-wifi-hotspot script and package makes it possible to easily share a wired internet connection via wifi hotspot with a single command.

The upcoming NixOS 22.05 repository will include this program. You can install and use it like this:

nix-env -iA nixos.linux-wifi-hotspot
sudo create_ap wlan0 eth0 MyAccessPoint

wlan0 is the interface name of your wifi card and eth0 the name of your network device which will provide the internet connection. The last argument of create_ap is the wifi network name (SSID). For information on further config parameters run create_ap without any argument.

It is possible that not any wifi card support access point mode. I’m using a Ralink device which has great open source driver and firmware support as mentioned in an earlier article.

Persistent configuration

Now to the part which especially applies to NixOS. An ongoing pull request will also bring a service module to NixOS systems to configure wifi hotspots persistent. All you need to do is add following lines to your system configuration:

services.create_ap = {
  enable = true;
  settings = {
    INTERNET_IFACE = "eth0";
    WIFI_IFACE = "wlan0";
    SSID = "My Wifi Hotspot";
    PASSPHRASE = "12345678";
  };
};

The settings parameter are based on the upstream configuration file syntax.

After applying this configuration, your system should automatically spawn the hotspot access point directly and after every reboot.

💬 Are you interested in our work or have some questions? Join us in our public Signal chat pi crew 👋
🪙 If you like our work or want to supprot us, you can donate MobileCoins to our address.

Leave a Reply

Your email address will not be published. Required fields are marked *