diff --git a/modules/module-list.nix b/modules/module-list.nix index 750a39ba105..429bcfcf1b8 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -64,6 +64,7 @@ ./services/networking/ssh/lshd.nix ./services/networking/ssh/sshd.nix ./services/networking/vsftpd.nix + ./services/networking/wpa_supplicant.nix ./services/printing/cupsd.nix ./services/scheduling/atd.nix ./services/scheduling/cron.nix diff --git a/modules/services/networking/wpa_supplicant.nix b/modules/services/networking/wpa_supplicant.nix new file mode 100644 index 00000000000..7cb75fd68a2 --- /dev/null +++ b/modules/services/networking/wpa_supplicant.nix @@ -0,0 +1,54 @@ +{pkgs, config, ...}: + +let + + configFile = "/etc/wpa_supplicant.conf"; + +in + +{ + + ###### interface + + options = { + + networking.enableWLAN = pkgs.lib.mkOption { + default = false; + description = '' + Whether to start wpa_supplicant to scan for + and associate with wireless networks. Note: NixOS currently + does not generate wpa_supplicant's + configuration file, ${configFile}. You + should edit this file yourself to define wireless networks, + WPA keys and so on (see + wpa_supplicant.conf + 5). + ''; + }; + + }; + + + ###### implementation + + config = pkgs.lib.mkIf config.networking.enableWLAN { + + environment.systemPackages = [pkgs.wpa_supplicant]; + + jobs = pkgs.lib.singleton + { name = "wpa_supplicant"; + + preStart = + '' + touch -a ${configFile} + chmod 600 ${configFile} + ''; + + exec = + "${pkgs.wpa_supplicant}/sbin/wpa_supplicant " + + "-C /var/run/wpa_supplicant -c ${configFile} -iwlan0"; + }; + + }; + +}