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