mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-19 07:59:24 +03:00

After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
175 lines
4.5 KiB
Nix
175 lines
4.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
cfg = config.services.connman;
|
|
configFile = pkgs.writeText "connman.conf" ''
|
|
[General]
|
|
NetworkInterfaceBlacklist=${lib.concatStringsSep "," cfg.networkInterfaceBlacklist}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
enableIwd = cfg.wifi.backend == "iwd";
|
|
in
|
|
{
|
|
meta.maintainers = with lib.maintainers; [ AndersonTorres ];
|
|
|
|
imports = [
|
|
(lib.mkRenamedOptionModule [ "networking" "connman" ] [ "services" "connman" ])
|
|
];
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
services.connman = {
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to use ConnMan for managing your network connections.
|
|
'';
|
|
};
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
description = "The connman package / build flavor";
|
|
default = pkgs.connman;
|
|
defaultText = lib.literalExpression "pkgs.connman";
|
|
example = lib.literalExpression "pkgs.connmanFull";
|
|
};
|
|
|
|
enableVPN = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = ''
|
|
Whether to enable ConnMan VPN service.
|
|
'';
|
|
};
|
|
|
|
extraConfig = lib.mkOption {
|
|
type = lib.types.lines;
|
|
default = "";
|
|
description = ''
|
|
Configuration lines appended to the generated connman configuration file.
|
|
'';
|
|
};
|
|
|
|
networkInterfaceBlacklist = lib.mkOption {
|
|
type = with lib.types; listOf str;
|
|
default = [
|
|
"vmnet"
|
|
"vboxnet"
|
|
"virbr"
|
|
"ifb"
|
|
"ve"
|
|
];
|
|
description = ''
|
|
Default blacklisted interfaces, this includes NixOS containers interfaces (ve).
|
|
'';
|
|
};
|
|
|
|
wifi = {
|
|
backend = lib.mkOption {
|
|
type = lib.types.enum [
|
|
"wpa_supplicant"
|
|
"iwd"
|
|
];
|
|
default = "wpa_supplicant";
|
|
description = ''
|
|
Specify the Wi-Fi backend used.
|
|
Currently supported are {option}`wpa_supplicant` or {option}`iwd`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
extraFlags = lib.mkOption {
|
|
type = with lib.types; listOf str;
|
|
default = [ ];
|
|
example = [ "--nodnsproxy" ];
|
|
description = ''
|
|
Extra flags to pass to connmand
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
{
|
|
assertion = !config.networking.useDHCP;
|
|
message = "You can not use services.connman with networking.useDHCP";
|
|
}
|
|
{
|
|
# TODO: connman seemingly can be used along network manager and
|
|
# connmanFull supports this - so this should be worked out somehow
|
|
assertion = !config.networking.networkmanager.enable;
|
|
message = "You can not use services.connman with networking.networkmanager";
|
|
}
|
|
];
|
|
|
|
environment.systemPackages = [ cfg.package ];
|
|
|
|
systemd.services.connman = {
|
|
description = "Connection service";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = lib.optional enableIwd "iwd.service";
|
|
requires = lib.optional enableIwd "iwd.service";
|
|
serviceConfig = {
|
|
Type = "dbus";
|
|
BusName = "net.connman";
|
|
Restart = "on-failure";
|
|
ExecStart = toString (
|
|
[
|
|
"${cfg.package}/sbin/connmand"
|
|
"--config=${configFile}"
|
|
"--nodaemon"
|
|
]
|
|
++ lib.optional enableIwd "--wifi=iwd_agent"
|
|
++ cfg.extraFlags
|
|
);
|
|
StandardOutput = "null";
|
|
};
|
|
};
|
|
|
|
systemd.services.connman-vpn = lib.mkIf cfg.enableVPN {
|
|
description = "ConnMan VPN service";
|
|
wantedBy = [ "multi-user.target" ];
|
|
before = [ "connman.service" ];
|
|
serviceConfig = {
|
|
Type = "dbus";
|
|
BusName = "net.connman.vpn";
|
|
ExecStart = "${cfg.package}/sbin/connman-vpnd -n";
|
|
StandardOutput = "null";
|
|
};
|
|
};
|
|
|
|
systemd.services.net-connman-vpn = lib.mkIf cfg.enableVPN {
|
|
description = "D-BUS Service";
|
|
serviceConfig = {
|
|
Name = "net.connman.vpn";
|
|
before = [ "connman.service" ];
|
|
ExecStart = "${cfg.package}/sbin/connman-vpnd -n";
|
|
User = "root";
|
|
SystemdService = "connman-vpn.service";
|
|
};
|
|
};
|
|
|
|
networking = {
|
|
useDHCP = false;
|
|
wireless = {
|
|
enable = lib.mkIf (!enableIwd) true;
|
|
dbusControlled = true;
|
|
iwd = lib.mkIf enableIwd {
|
|
enable = true;
|
|
};
|
|
};
|
|
networkmanager.enable = false;
|
|
};
|
|
};
|
|
}
|