mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-28 18:03:04 +00:00
2e751c0772
the conversion procedure is simple: - find all things that look like options, ie calls to either `mkOption` or `lib.mkOption` that take an attrset. remember the attrset as the option - for all options, find a `description` attribute who's value is not a call to `mdDoc` or `lib.mdDoc` - textually convert the entire value of the attribute to MD with a few simple regexes (the set from mdize-module.sh) - if the change produced a change in the manual output, discard - if the change kept the manual unchanged, add some text to the description to make sure we've actually found an option. if the manual changes this time, keep the converted description this procedure converts 80% of nixos options to markdown. around 2000 options remain to be inspected, but most of those fail the "does not change the manual output check": currently the MD conversion process does not faithfully convert docbook tags like <code> and <package>, so any option using such tags will not be converted at all.
163 lines
4.3 KiB
Nix
163 lines
4.3 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with pkgs;
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.connman;
|
|
configFile = pkgs.writeText "connman.conf" ''
|
|
[General]
|
|
NetworkInterfaceBlacklist=${concatStringsSep "," cfg.networkInterfaceBlacklist}
|
|
|
|
${cfg.extraConfig}
|
|
'';
|
|
enableIwd = cfg.wifi.backend == "iwd";
|
|
in {
|
|
|
|
imports = [
|
|
(mkRenamedOptionModule [ "networking" "connman" ] [ "services" "connman" ])
|
|
];
|
|
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
services.connman = {
|
|
|
|
enable = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc ''
|
|
Whether to use ConnMan for managing your network connections.
|
|
'';
|
|
};
|
|
|
|
enableVPN = mkOption {
|
|
type = types.bool;
|
|
default = true;
|
|
description = lib.mdDoc ''
|
|
Whether to enable ConnMan VPN service.
|
|
'';
|
|
};
|
|
|
|
extraConfig = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = lib.mdDoc ''
|
|
Configuration lines appended to the generated connman configuration file.
|
|
'';
|
|
};
|
|
|
|
networkInterfaceBlacklist = mkOption {
|
|
type = with types; listOf str;
|
|
default = [ "vmnet" "vboxnet" "virbr" "ifb" "ve" ];
|
|
description = lib.mdDoc ''
|
|
Default blacklisted interfaces, this includes NixOS containers interfaces (ve).
|
|
'';
|
|
};
|
|
|
|
wifi = {
|
|
backend = mkOption {
|
|
type = types.enum [ "wpa_supplicant" "iwd" ];
|
|
default = "wpa_supplicant";
|
|
description = lib.mdDoc ''
|
|
Specify the Wi-Fi backend used.
|
|
Currently supported are {option}`wpa_supplicant` or {option}`iwd`.
|
|
'';
|
|
};
|
|
};
|
|
|
|
extraFlags = mkOption {
|
|
type = with types; listOf str;
|
|
default = [ ];
|
|
example = [ "--nodnsproxy" ];
|
|
description = lib.mdDoc ''
|
|
Extra flags to pass to connmand
|
|
'';
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
description = lib.mdDoc "The connman package / build flavor";
|
|
default = connman;
|
|
defaultText = literalExpression "pkgs.connman";
|
|
example = literalExpression "pkgs.connmanFull";
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
###### implementation
|
|
|
|
config = 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 = [ "syslog.target" ] ++ optional enableIwd "iwd.service";
|
|
requires = optional enableIwd "iwd.service";
|
|
serviceConfig = {
|
|
Type = "dbus";
|
|
BusName = "net.connman";
|
|
Restart = "on-failure";
|
|
ExecStart = toString ([
|
|
"${cfg.package}/sbin/connmand"
|
|
"--config=${configFile}"
|
|
"--nodaemon"
|
|
] ++ optional enableIwd "--wifi=iwd_agent"
|
|
++ cfg.extraFlags);
|
|
StandardOutput = "null";
|
|
};
|
|
};
|
|
|
|
systemd.services.connman-vpn = mkIf cfg.enableVPN {
|
|
description = "ConnMan VPN service";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "syslog.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 = 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 = mkIf (!enableIwd) true;
|
|
dbusControlled = true;
|
|
iwd = mkIf enableIwd {
|
|
enable = true;
|
|
};
|
|
};
|
|
networkmanager.enable = false;
|
|
};
|
|
};
|
|
}
|