3
0
Fork 0
forked from mirrors/nixpkgs

nixos/connman: optional iwd backend

This commit is contained in:
arcnmx 2019-12-21 13:48:15 -08:00
parent b1b55ba0f6
commit 7753d58e89

View file

@ -11,6 +11,7 @@ let
${cfg.extraConfig} ${cfg.extraConfig}
''; '';
enableIwd = cfg.wifi.backend == "iwd";
in { in {
imports = [ 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 { extraFlags = mkOption {
type = with types; listOf str; type = with types; listOf str;
default = [ ]; default = [ ];
@ -76,9 +88,6 @@ in {
assertions = [{ assertions = [{
assertion = !config.networking.useDHCP; assertion = !config.networking.useDHCP;
message = "You can not use services.connman with 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; assertion = !config.networking.networkmanager.enable;
message = "You can not use services.connman with networking.networkmanager"; message = "You can not use services.connman with networking.networkmanager";
@ -89,12 +98,18 @@ in {
systemd.services.connman = { systemd.services.connman = {
description = "Connection service"; description = "Connection service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
after = [ "syslog.target" ]; after = [ "syslog.target" ] ++ optional enableIwd "iwd.service";
requires = optional enableIwd "iwd.service";
serviceConfig = { serviceConfig = {
Type = "dbus"; Type = "dbus";
BusName = "net.connman"; BusName = "net.connman";
Restart = "on-failure"; 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"; StandardOutput = "null";
}; };
}; };
@ -125,7 +140,12 @@ in {
networking = { networking = {
useDHCP = false; useDHCP = false;
wireless.enable = true; wireless = {
enable = mkIf (!enableIwd) true;
iwd = mkIf enableIwd {
enable = true;
};
};
networkmanager.enable = false; networkmanager.enable = false;
}; };
}; };