@@ -5,12 +5,7 @@ with lib;
55let
66 cfg = config.networking.wireless;
77 configFile = "/etc/wpa_supplicant.conf";
8−in
9−
10−{
11−
12− ###### interface
13−
8+in {
149 options = {
1510 networking.wireless = {
1611 enable = mkOption {
@@ -73,19 +68,17 @@ in
7368 };
7469 };
7570
71+ config = mkMerge [
72+ (mkIf cfg.enable {
73+ environment.systemPackages = [ pkgs.wpa_supplicant ];
7674
77− ###### implementation
78−
79− config = mkIf cfg.enable {
80−
81− environment.systemPackages = [ pkgs.wpa_supplicant ];
82−
83− services.dbus.packages = [ pkgs.wpa_supplicant ];
75+ services.dbus.packages = [ pkgs.wpa_supplicant ];
8476
85− # FIXME: start a separate wpa_supplicant instance per interface.
86− jobs.wpa_supplicant = let
87− ifaces = cfg.interfaces;
88− in { description = "WPA Supplicant";
77+ # FIXME: start a separate wpa_supplicant instance per interface.
78+ systemd.services.wpa_supplicant = let
79+ ifaces = cfg.interfaces;
80+ in {
81+ description = "WPA Supplicant";
8982
9083 wantedBy = [ "network.target" ];
9184
@@ -101,37 +94,33 @@ in
10194 fi
10295 '';
10396
104− script =
105− ''
106− ${if ifaces == [] then ''
107− for i in $(cd /sys/class/net && echo *); do
108− DEVTYPE=
109− source /sys/class/net/$i/uevent
110− if [ "$DEVTYPE" = "wlan" -o -e /sys/class/net/$i/wireless ]; then
111− ifaces="$ifaces''${ifaces:+ -N} -i$i"
112− fi
113− done
114− '' else ''
115− ifaces="${concatStringsSep " -N " (map (i: "-i${i}") ifaces)}"
116− ''}
117− exec wpa_supplicant -s -u -D${cfg.driver} -c ${configFile} $ifaces
118− '';
97+ script = ''
98+ ${if ifaces == [] then ''
99+ for i in $(cd /sys/class/net && echo *); do
100+ DEVTYPE=
101+ source /sys/class/net/$i/uevent
102+ if [ "$DEVTYPE" = "wlan" -o -e /sys/class/net/$i/wireless ]; then
103+ ifaces="$ifaces''${ifaces:+ -N} -i$i"
104+ fi
105+ done
106+ '' else ''
107+ ifaces="${concatStringsSep " -N " (map (i: "-i${i}") ifaces)}"
108+ ''}
109+ exec wpa_supplicant -s -u -D${cfg.driver} -c ${configFile} $ifaces
110+ '';
119111 };
120112
121− powerManagement.resumeCommands =
122− ''
113+ powerManagement.resumeCommands = ''
123114 ${config.systemd.package}/bin/systemctl try-restart wpa_supplicant
124115 '';
125116
126− assertions = [{ assertion = !cfg.userControlled.enable || cfg.interfaces != [];
127− message = "user controlled wpa_supplicant needs explicit networking.wireless.interfaces";}];
128−
129− # Restart wpa_supplicant when a wlan device appears or disappears.
130− services.udev.extraRules =
131− ''
117+ # Restart wpa_supplicant when a wlan device appears or disappears.
118+ services.udev.extraRules = ''
132119 ACTION=="add|remove", SUBSYSTEM=="net", ENV{DEVTYPE}=="wlan", RUN+="${config.systemd.package}/bin/systemctl try-restart wpa_supplicant.service"
133120 '';
134−
135− };
136−
121+ })
122+ {
123+ meta.maintainers = with lib.maintainers; [ globin ];
124+ }
125+ ];
137126}