nixos/networkmanager: fix for rootless wpa_supplicant
This commit is contained in:
@@ -11,7 +11,8 @@ let
|
||||
cfg = config.networking.networkmanager;
|
||||
ini = pkgs.formats.ini { };
|
||||
|
||||
delegateWireless = config.networking.wireless.enable == true && cfg.unmanaged != [ ];
|
||||
# Whether wpa_supplicant is managed independently
|
||||
delegateWireless = config.networking.wireless.networks != { } && cfg.unmanaged != [ ];
|
||||
|
||||
enableIwd = cfg.wifi.backend == "iwd";
|
||||
|
||||
@@ -136,10 +137,7 @@ let
|
||||
cfg.package
|
||||
]
|
||||
++ cfg.plugins
|
||||
++ pluginRuntimeDeps
|
||||
++ lib.optionals (!delegateWireless && !enableIwd) [
|
||||
pkgs.wpa_supplicant
|
||||
];
|
||||
++ pluginRuntimeDeps;
|
||||
in
|
||||
{
|
||||
|
||||
@@ -541,9 +539,9 @@ in
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.networking.wireless.enable == true -> cfg.unmanaged != [ ];
|
||||
assertion = config.networking.wireless.networks != { } -> cfg.unmanaged != [ ];
|
||||
message = ''
|
||||
You can not use networking.networkmanager with networking.wireless.
|
||||
You can not use networking.networkmanager with networking.wireless.networks.
|
||||
Except if you mark some interfaces as <literal>unmanaged</literal> by NetworkManager.
|
||||
'';
|
||||
}
|
||||
@@ -676,6 +674,13 @@ in
|
||||
useDHCP = false;
|
||||
})
|
||||
|
||||
(mkIf (!delegateWireless && !enableIwd) {
|
||||
# Enable wpa_supplicant but fully control it over DBus
|
||||
wireless.enable = true;
|
||||
wireless.autoDetectInterfaces = false;
|
||||
wireless.dbusControlled = true;
|
||||
})
|
||||
|
||||
(mkIf enableIwd {
|
||||
wireless.iwd.enable = true;
|
||||
})
|
||||
|
||||
@@ -199,7 +199,12 @@ let
|
||||
script = ''
|
||||
iface_args="-s ${optionalString cfg.dbusControlled "-u"} -D${cfg.driver} ${configStr}"
|
||||
${
|
||||
if iface == null then
|
||||
if iface != null then
|
||||
''
|
||||
# add known interface to the daemon arguments
|
||||
args="-i${iface} $iface_args"
|
||||
''
|
||||
else if cfg.autoDetectInterfaces then
|
||||
''
|
||||
# detect interfaces automatically
|
||||
|
||||
@@ -222,10 +227,7 @@ let
|
||||
done
|
||||
''
|
||||
else
|
||||
''
|
||||
# add known interface to the daemon arguments
|
||||
args="-i${iface} $iface_args"
|
||||
''
|
||||
"args=$iface_args"
|
||||
}
|
||||
|
||||
# finally start daemon
|
||||
@@ -251,7 +253,8 @@ in
|
||||
"wlan1"
|
||||
];
|
||||
description = ''
|
||||
The interfaces {command}`wpa_supplicant` will use. If empty, it will
|
||||
The interfaces {command}`wpa_supplicant` will use. If empty and
|
||||
[](#opt-networking.wireless.autoDetectInterfaces) is true it will
|
||||
automatically use all wireless interfaces.
|
||||
|
||||
::: {.note}
|
||||
@@ -260,6 +263,10 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
autoDetectInterfaces = mkEnableOption "automatic detection of wireless interfaces" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
driver = mkOption {
|
||||
type = types.str;
|
||||
default = "nl80211,wext";
|
||||
|
||||
Reference in New Issue
Block a user