2014-04-14 14:26:48 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
2014-01-04 00:13:26 +00:00
|
|
|
|
|
|
|
with pkgs;
|
2014-05-05 18:58:51 +00:00
|
|
|
with lib;
|
2014-01-04 00:13:26 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.networking.connman;
|
2015-09-12 12:28:53 +00:00
|
|
|
configFile = pkgs.writeText "connman.conf" ''
|
|
|
|
[General]
|
|
|
|
NetworkInterfaceBlacklist=${concatStringsSep "," cfg.networkInterfaceBlacklist}
|
2014-01-04 00:13:26 +00:00
|
|
|
|
2015-09-12 12:28:53 +00:00
|
|
|
${cfg.extraConfig}
|
|
|
|
'';
|
2014-01-04 00:13:26 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
networking.connman = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to use ConnMan for managing your network connections.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-09-25 06:02:29 +00:00
|
|
|
enableVPN = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = ''
|
|
|
|
Whether to enable ConnMan VPN service.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-09-12 12:28:53 +00:00
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = ''
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Configuration lines appended to the generated connman configuration file.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
networkInterfaceBlacklist = mkOption {
|
|
|
|
type = with types; listOf string;
|
|
|
|
default = [ "vmnet" "vboxnet" "virbr" "ifb" "ve" ];
|
|
|
|
description = ''
|
|
|
|
Default blacklisted interfaces, this includes NixOS containers interfaces (ve).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2016-09-13 18:10:03 +00:00
|
|
|
extraFlags = mkOption {
|
|
|
|
type = with types; listOf string;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "--nodnsproxy" ];
|
|
|
|
description = ''
|
|
|
|
Extra flags to pass to connmand
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-01-04 00:13:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
assertions = [{
|
2016-02-01 16:51:04 +00:00
|
|
|
assertion = !config.networking.useDHCP;
|
2014-01-04 00:13:26 +00:00
|
|
|
message = "You can not use services.networking.connman with services.networking.useDHCP";
|
|
|
|
}{
|
2016-02-01 16:51:04 +00:00
|
|
|
assertion = config.networking.wireless.enable;
|
2014-01-04 00:13:26 +00:00
|
|
|
message = "You must use services.networking.connman with services.networking.wireless";
|
|
|
|
}{
|
2016-02-01 18:33:50 +00:00
|
|
|
assertion = !config.networking.networkmanager.enable;
|
2014-01-04 00:13:26 +00:00
|
|
|
message = "You can not use services.networking.connman with services.networking.networkmanager";
|
|
|
|
}];
|
|
|
|
|
|
|
|
environment.systemPackages = [ connman ];
|
|
|
|
|
|
|
|
systemd.services."connman" = {
|
|
|
|
description = "Connection service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "syslog.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "net.connman";
|
|
|
|
Restart = "on-failure";
|
2016-09-13 18:10:03 +00:00
|
|
|
ExecStart = "${pkgs.connman}/sbin/connmand --config=${configFile} --nodaemon ${toString cfg.extraFlags}";
|
2014-01-04 00:13:26 +00:00
|
|
|
StandardOutput = "null";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-09-25 06:02:29 +00:00
|
|
|
systemd.services."connman-vpn" = mkIf cfg.enableVPN {
|
2014-01-04 00:13:26 +00:00
|
|
|
description = "ConnMan VPN service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "syslog.target" ];
|
2014-01-11 20:17:17 +00:00
|
|
|
before = [ "connman" ];
|
2014-01-04 00:13:26 +00:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "dbus";
|
|
|
|
BusName = "net.connman.vpn";
|
|
|
|
ExecStart = "${pkgs.connman}/sbin/connman-vpnd -n";
|
|
|
|
StandardOutput = "null";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-09-25 06:02:29 +00:00
|
|
|
systemd.services."net-connman-vpn" = mkIf cfg.enableVPN {
|
2014-01-04 00:13:26 +00:00
|
|
|
description = "D-BUS Service";
|
|
|
|
serviceConfig = {
|
|
|
|
Name = "net.connman.vpn";
|
2014-01-11 20:17:17 +00:00
|
|
|
before = [ "connman" ];
|
2014-01-04 00:13:26 +00:00
|
|
|
ExecStart = "${pkgs.connman}/sbin/connman-vpnd -n";
|
|
|
|
User = "root";
|
|
|
|
SystemdService = "connman-vpn.service";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
useDHCP = false;
|
|
|
|
wireless.enable = true;
|
|
|
|
networkmanager.enable = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|