Merge pull request #76153 from arcnmx/connman-iwd

nixos/connman: optional iwd backend
This commit is contained in:
Christian Kauhaus 2020-01-02 21:35:54 +01:00 committed by GitHub
commit 129c73802f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ let
${cfg.extraConfig}
'';
enableIwd = cfg.wifi.backend == "iwd";
in {
imports = [
@ -56,6 +57,17 @@ in {
'';
};
wifi = {
backend = mkOption {
type = types.enum [ "wpa_supplicant" "iwd" ];
default = "wpa_supplicant";
description = ''
Specify the Wi-Fi backend used.
Currently supported are <option>wpa_supplicant</option> or <option>iwd</option>.
'';
};
};
extraFlags = mkOption {
type = with types; listOf str;
default = [ ];
@ -76,9 +88,6 @@ in {
assertions = [{
assertion = !config.networking.useDHCP;
message = "You can not use services.connman with networking.useDHCP";
}{
assertion = config.networking.wireless.enable;
message = "You must use services.connman with networking.wireless";
}{
assertion = !config.networking.networkmanager.enable;
message = "You can not use services.connman with networking.networkmanager";
@ -89,12 +98,18 @@ in {
systemd.services.connman = {
description = "Connection service";
wantedBy = [ "multi-user.target" ];
after = [ "syslog.target" ];
after = [ "syslog.target" ] ++ optional enableIwd "iwd.service";
requires = optional enableIwd "iwd.service";
serviceConfig = {
Type = "dbus";
BusName = "net.connman";
Restart = "on-failure";
ExecStart = "${pkgs.connman}/sbin/connmand --config=${configFile} --nodaemon ${toString cfg.extraFlags}";
ExecStart = toString ([
"${pkgs.connman}/sbin/connmand"
"--config=${configFile}"
"--nodaemon"
] ++ optional enableIwd "--wifi=iwd_agent"
++ cfg.extraFlags);
StandardOutput = "null";
};
};
@ -125,7 +140,12 @@ in {
networking = {
useDHCP = false;
wireless.enable = true;
wireless = {
enable = mkIf (!enableIwd) true;
iwd = mkIf enableIwd {
enable = true;
};
};
networkmanager.enable = false;
};
};