9 cfg = config.services.connman;
10 configFile = pkgs.writeText "connman.conf" ''
12 NetworkInterfaceBlacklist=${lib.concatStringsSep "," cfg.networkInterfaceBlacklist}
16 enableIwd = cfg.wifi.backend == "iwd";
19 meta.maintainers = with lib.maintainers; [ ];
22 (lib.mkRenamedOptionModule [ "networking" "connman" ] [ "services" "connman" ])
29 enable = lib.mkOption {
30 type = lib.types.bool;
33 Whether to use ConnMan for managing your network connections.
37 package = lib.mkOption {
38 type = lib.types.package;
39 description = "The connman package / build flavor";
40 default = pkgs.connman;
41 defaultText = lib.literalExpression "pkgs.connman";
42 example = lib.literalExpression "pkgs.connmanFull";
45 enableVPN = lib.mkOption {
46 type = lib.types.bool;
49 Whether to enable ConnMan VPN service.
53 extraConfig = lib.mkOption {
54 type = lib.types.lines;
57 Configuration lines appended to the generated connman configuration file.
61 networkInterfaceBlacklist = lib.mkOption {
62 type = with lib.types; listOf str;
71 Default blacklisted interfaces, this includes NixOS containers interfaces (ve).
76 backend = lib.mkOption {
77 type = lib.types.enum [
81 default = "wpa_supplicant";
83 Specify the Wi-Fi backend used.
84 Currently supported are {option}`wpa_supplicant` or {option}`iwd`.
89 extraFlags = lib.mkOption {
90 type = with lib.types; listOf str;
92 example = [ "--nodnsproxy" ];
94 Extra flags to pass to connmand
100 ###### implementation
102 config = lib.mkIf cfg.enable {
105 assertion = !config.networking.useDHCP;
106 message = "You can not use services.connman with networking.useDHCP";
109 # TODO: connman seemingly can be used along network manager and
110 # connmanFull supports this - so this should be worked out somehow
111 assertion = !config.networking.networkmanager.enable;
112 message = "You can not use services.connman with networking.networkmanager";
116 environment.systemPackages = [ cfg.package ];
118 systemd.services.connman = {
119 description = "Connection service";
120 wantedBy = [ "multi-user.target" ];
121 after = lib.optional enableIwd "iwd.service";
122 requires = lib.optional enableIwd "iwd.service";
125 BusName = "net.connman";
126 Restart = "on-failure";
127 ExecStart = toString (
129 "${cfg.package}/sbin/connmand"
130 "--config=${configFile}"
133 ++ lib.optional enableIwd "--wifi=iwd_agent"
136 StandardOutput = "null";
140 systemd.services.connman-vpn = lib.mkIf cfg.enableVPN {
141 description = "ConnMan VPN service";
142 wantedBy = [ "multi-user.target" ];
143 before = [ "connman.service" ];
146 BusName = "net.connman.vpn";
147 ExecStart = "${cfg.package}/sbin/connman-vpnd -n";
148 StandardOutput = "null";
152 systemd.services.net-connman-vpn = lib.mkIf cfg.enableVPN {
153 description = "D-BUS Service";
155 Name = "net.connman.vpn";
156 before = [ "connman.service" ];
157 ExecStart = "${cfg.package}/sbin/connman-vpnd -n";
159 SystemdService = "connman-vpn.service";
166 enable = lib.mkIf (!enableIwd) true;
167 dbusControlled = true;
168 iwd = lib.mkIf enableIwd {
172 networkmanager.enable = false;