1{ pkgs, lib, ... }:
2{
3 name = "connman";
4 meta = with lib.maintainers; {
5 maintainers = [ rnhmjoj ];
6 };
7
8 # Router running radvd on VLAN 1
9 nodes.router =
10 { ... }:
11 {
12 imports = [ ../modules/profiles/minimal.nix ];
13
14 virtualisation.vlans = [ 1 ];
15
16 boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = true;
17
18 networking = {
19 useDHCP = false;
20 interfaces.eth1.ipv6.addresses = [
21 {
22 address = "fd12::1";
23 prefixLength = 64;
24 }
25 ];
26 };
27
28 services.radvd = {
29 enable = true;
30 config = ''
31 interface eth1 {
32 AdvSendAdvert on;
33 AdvManagedFlag on;
34 AdvOtherConfigFlag on;
35 prefix fd12::/64 {
36 AdvAutonomous off;
37 };
38 };
39 '';
40 };
41 };
42
43 # Client running connman, connected to VLAN 1
44 nodes.client =
45 { ... }:
46 {
47 virtualisation.vlans = [ 1 ];
48
49 # add a virtual wlan interface
50 boot.kernelModules = [ "mac80211_hwsim" ];
51 boot.extraModprobeConfig = ''
52 options mac80211_hwsim radios=1
53 '';
54
55 # Note: the overrides are needed because the wifi is
56 # disabled with mkVMOverride in qemu-vm.nix.
57 services.connman.enable = lib.mkOverride 0 true;
58 services.connman.networkInterfaceBlacklist = [ "eth0" ];
59 networking.wireless.enable = lib.mkOverride 0 true;
60 networking.wireless.interfaces = [ "wlan0" ];
61 };
62
63 testScript = ''
64 start_all()
65
66 with subtest("Router is ready"):
67 router.wait_for_unit("radvd.service")
68
69 with subtest("Daemons are running"):
70 client.wait_for_unit("wpa_supplicant-wlan0.service")
71 client.wait_for_unit("connman.service")
72 client.wait_until_succeeds("connmanctl state | grep -q ready")
73
74 with subtest("Wired interface is configured"):
75 client.wait_until_succeeds("ip -6 route | grep -q fd12::/64")
76 client.wait_until_succeeds("ping -c 1 fd12::1")
77
78 with subtest("Can set up a wireless access point"):
79 client.succeed("connmanctl enable wifi")
80 client.wait_until_succeeds("connmanctl tether wifi on nixos-test reproducibility | grep -q 'Enabled'")
81 client.wait_until_succeeds("iw wlan0 info | grep -q nixos-test")
82 '';
83}