at master 3.9 kB view raw
1{ 2 name = "adguardhome"; 3 4 nodes = { 5 nullConf = { 6 services.adguardhome.enable = true; 7 }; 8 9 emptyConf = { 10 services.adguardhome = { 11 enable = true; 12 13 settings = { }; 14 }; 15 }; 16 17 schemaVersionBefore23 = { 18 services.adguardhome = { 19 enable = true; 20 21 settings.schema_version = 20; 22 }; 23 }; 24 25 declarativeConf = { 26 services.adguardhome = { 27 enable = true; 28 29 mutableSettings = false; 30 settings.dns.bootstrap_dns = [ "127.0.0.1" ]; 31 }; 32 }; 33 34 mixedConf = { 35 services.adguardhome = { 36 enable = true; 37 38 mutableSettings = true; 39 settings.dns.bootstrap_dns = [ "127.0.0.1" ]; 40 }; 41 }; 42 43 dhcpConf = 44 { lib, ... }: 45 { 46 virtualisation.vlans = [ 1 ]; 47 48 networking = { 49 # Configure static IP for DHCP server 50 useDHCP = false; 51 interfaces."eth1" = lib.mkForce { 52 useDHCP = false; 53 ipv4 = { 54 addresses = [ 55 { 56 address = "10.0.10.1"; 57 prefixLength = 24; 58 } 59 ]; 60 61 routes = [ 62 { 63 address = "10.0.10.0"; 64 prefixLength = 24; 65 } 66 ]; 67 }; 68 }; 69 70 # Required for DHCP 71 firewall.allowedUDPPorts = [ 72 67 73 68 74 ]; 75 }; 76 77 services.adguardhome = { 78 enable = true; 79 allowDHCP = true; 80 mutableSettings = false; 81 settings = { 82 dns.bootstrap_dns = [ "127.0.0.1" ]; 83 dhcp = { 84 # This implicitly enables CAP_NET_RAW 85 enabled = true; 86 interface_name = "eth1"; 87 local_domain_name = "lan"; 88 dhcpv4 = { 89 gateway_ip = "10.0.10.1"; 90 range_start = "10.0.10.100"; 91 range_end = "10.0.10.101"; 92 subnet_mask = "255.255.255.0"; 93 }; 94 }; 95 }; 96 }; 97 }; 98 99 client = 100 { lib, ... }: 101 { 102 virtualisation.vlans = [ 1 ]; 103 networking = { 104 interfaces.eth1 = { 105 useDHCP = true; 106 ipv4.addresses = lib.mkForce [ ]; 107 }; 108 }; 109 }; 110 }; 111 112 testScript = '' 113 with subtest("Minimal (settings = null) config test"): 114 nullConf.wait_for_unit("adguardhome.service") 115 nullConf.wait_for_open_port(3000) 116 117 with subtest("Default config test"): 118 emptyConf.wait_for_unit("adguardhome.service") 119 emptyConf.wait_for_open_port(3000) 120 121 with subtest("Default schema_version 23 config test"): 122 schemaVersionBefore23.wait_for_unit("adguardhome.service") 123 schemaVersionBefore23.wait_for_open_port(3000) 124 125 with subtest("Declarative config test, DNS will be reachable"): 126 declarativeConf.wait_for_unit("adguardhome.service") 127 declarativeConf.wait_for_open_port(53) 128 declarativeConf.wait_for_open_port(3000) 129 130 with subtest("Mixed config test, check whether merging works"): 131 mixedConf.wait_for_unit("adguardhome.service") 132 mixedConf.wait_for_open_port(53) 133 mixedConf.wait_for_open_port(3000) 134 # Test whether merging works properly, even if nothing is changed 135 mixedConf.systemctl("restart adguardhome.service") 136 mixedConf.wait_for_unit("adguardhome.service") 137 mixedConf.wait_for_open_port(3000) 138 139 with subtest("Testing successful DHCP start"): 140 dhcpConf.wait_for_unit("adguardhome.service") 141 client.systemctl("start network-online.target") 142 client.wait_for_unit("network-online.target") 143 # Test IP assignment via DHCP 144 dhcpConf.wait_until_succeeds("ping -c 5 10.0.10.100") 145 # Test hostname resolution over DHCP-provided DNS 146 dhcpConf.wait_until_succeeds("ping -c 5 client.lan") 147 ''; 148}