about summary refs log tree commit diff
path: root/nixos/modules/services/networking/connman.nix
blob: 2b26fe88129b2c7d18f0d13af10102f639fe4183 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
{ config, pkgs, ... }:

with pkgs.lib;
with pkgs;

let
  cfg = config.networking.connman;

in {

  ###### interface

  options = {

    networking.connman = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to use ConnMan for managing your network connections.
        '';
      };

    };

  };

  ###### implementation

  config = mkIf cfg.enable {

    assertions = [{
      assertion = config.networking.useDHCP == false;
      message = "You can not use services.networking.connman with services.networking.useDHCP";
    }{
      assertion = config.networking.wireless.enable == true;
      message = "You must use services.networking.connman with services.networking.wireless";
    }{
      assertion = config.networking.networkmanager.enable == false;
      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";
        ExecStart = "${pkgs.connman}/sbin/connmand --nodaemon";
        StandardOutput = "null";
      };
    };

    systemd.services."connman-vpn" = {
      description = "ConnMan VPN service";
      wantedBy = [ "multi-user.target" ];
      after = [ "syslog.target" ];
      before = [ "connman" ];
      serviceConfig = {
        Type = "dbus";
        BusName = "net.connman.vpn";
        ExecStart = "${pkgs.connman}/sbin/connman-vpnd -n";
        StandardOutput = "null";
      };
    };

    systemd.services."net-connman-vpn" = {
      description = "D-BUS Service";
      serviceConfig = {
        Name = "net.connman.vpn";
        before = [ "connman" ];
        ExecStart = "${pkgs.connman}/sbin/connman-vpnd -n";
        User = "root";
        SystemdService = "connman-vpn.service";
      };
    };

    networking = {
      useDHCP = false;
      wireless.enable = true;
      networkmanager.enable = false;
    };

    powerManagement.resumeCommands = ''
      systemctl restart connman
    '';

  };
}