2022-06-09 17:43:22 +02:00
|
|
|
{
|
2022-01-17 01:39:27 +01:00
|
|
|
name = "adguardhome";
|
|
|
|
|
|
|
|
nodes = {
|
2024-04-19 18:37:19 +02:00
|
|
|
nullConf = { services.adguardhome.enable = true; };
|
2022-10-30 18:34:01 +01:00
|
|
|
|
2024-04-19 18:37:19 +02:00
|
|
|
emptyConf = {
|
2022-10-30 18:34:01 +01:00
|
|
|
services.adguardhome = {
|
|
|
|
enable = true;
|
2024-04-19 18:37:19 +02:00
|
|
|
|
|
|
|
settings = { };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
schemaVersionBefore23 = {
|
|
|
|
services.adguardhome = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
settings.schema_version = 20;
|
2022-10-30 18:34:01 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-19 18:37:19 +02:00
|
|
|
declarativeConf = {
|
2022-01-17 01:39:27 +01:00
|
|
|
services.adguardhome = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
mutableSettings = false;
|
2024-04-19 18:37:19 +02:00
|
|
|
settings.dns.bootstrap_dns = [ "127.0.0.1" ];
|
2022-01-17 01:39:27 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-04-19 18:37:19 +02:00
|
|
|
mixedConf = {
|
2022-01-17 01:39:27 +01:00
|
|
|
services.adguardhome = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
mutableSettings = true;
|
2024-04-19 18:37:19 +02:00
|
|
|
settings.dns.bootstrap_dns = [ "127.0.0.1" ];
|
2022-01-17 01:39:27 +01:00
|
|
|
};
|
|
|
|
};
|
2023-01-04 18:32:27 +01:00
|
|
|
|
|
|
|
dhcpConf = { lib, ... }: {
|
|
|
|
virtualisation.vlans = [ 1 ];
|
|
|
|
|
|
|
|
networking = {
|
|
|
|
# Configure static IP for DHCP server
|
|
|
|
useDHCP = false;
|
|
|
|
interfaces."eth1" = lib.mkForce {
|
|
|
|
useDHCP = false;
|
|
|
|
ipv4 = {
|
|
|
|
addresses = [{
|
|
|
|
address = "10.0.10.1";
|
|
|
|
prefixLength = 24;
|
|
|
|
}];
|
|
|
|
|
|
|
|
routes = [{
|
|
|
|
address = "10.0.10.0";
|
|
|
|
prefixLength = 24;
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Required for DHCP
|
|
|
|
firewall.allowedUDPPorts = [ 67 68 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
services.adguardhome = {
|
|
|
|
enable = true;
|
|
|
|
allowDHCP = true;
|
|
|
|
mutableSettings = false;
|
|
|
|
settings = {
|
2024-04-19 18:37:19 +02:00
|
|
|
dns.bootstrap_dns = [ "127.0.0.1" ];
|
2023-01-04 18:32:27 +01:00
|
|
|
dhcp = {
|
|
|
|
# This implicitly enables CAP_NET_RAW
|
|
|
|
enabled = true;
|
|
|
|
interface_name = "eth1";
|
|
|
|
local_domain_name = "lan";
|
|
|
|
dhcpv4 = {
|
|
|
|
gateway_ip = "10.0.10.1";
|
|
|
|
range_start = "10.0.10.100";
|
|
|
|
range_end = "10.0.10.101";
|
|
|
|
subnet_mask = "255.255.255.0";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
client = { lib, ... }: {
|
|
|
|
virtualisation.vlans = [ 1 ];
|
|
|
|
networking = {
|
|
|
|
interfaces.eth1 = {
|
|
|
|
useDHCP = true;
|
|
|
|
ipv4.addresses = lib.mkForce [ ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-01-17 01:39:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2022-10-30 18:34:01 +01:00
|
|
|
with subtest("Minimal (settings = null) config test"):
|
2024-04-19 18:37:19 +02:00
|
|
|
nullConf.wait_for_unit("adguardhome.service")
|
|
|
|
nullConf.wait_for_open_port(3000)
|
2022-10-30 18:34:01 +01:00
|
|
|
|
|
|
|
with subtest("Default config test"):
|
2024-04-19 18:37:19 +02:00
|
|
|
emptyConf.wait_for_unit("adguardhome.service")
|
|
|
|
emptyConf.wait_for_open_port(3000)
|
|
|
|
|
|
|
|
with subtest("Default schema_version 23 config test"):
|
|
|
|
schemaVersionBefore23.wait_for_unit("adguardhome.service")
|
|
|
|
schemaVersionBefore23.wait_for_open_port(3000)
|
2022-10-30 18:34:01 +01:00
|
|
|
|
2022-01-17 01:39:27 +01:00
|
|
|
with subtest("Declarative config test, DNS will be reachable"):
|
2024-04-19 18:37:19 +02:00
|
|
|
declarativeConf.wait_for_unit("adguardhome.service")
|
|
|
|
declarativeConf.wait_for_open_port(53)
|
|
|
|
declarativeConf.wait_for_open_port(3000)
|
2022-01-17 01:39:27 +01:00
|
|
|
|
|
|
|
with subtest("Mixed config test, check whether merging works"):
|
2024-04-19 18:37:19 +02:00
|
|
|
mixedConf.wait_for_unit("adguardhome.service")
|
|
|
|
mixedConf.wait_for_open_port(53)
|
|
|
|
mixedConf.wait_for_open_port(3000)
|
|
|
|
# Test whether merging works properly, even if nothing is changed
|
|
|
|
mixedConf.systemctl("restart adguardhome.service")
|
|
|
|
mixedConf.wait_for_unit("adguardhome.service")
|
|
|
|
mixedConf.wait_for_open_port(3000)
|
2023-01-04 18:32:27 +01:00
|
|
|
|
|
|
|
with subtest("Testing successful DHCP start"):
|
2024-04-19 18:37:19 +02:00
|
|
|
dhcpConf.wait_for_unit("adguardhome.service")
|
|
|
|
client.systemctl("start network-online.target")
|
|
|
|
client.wait_for_unit("network-online.target")
|
|
|
|
# Test IP assignment via DHCP
|
|
|
|
dhcpConf.wait_until_succeeds("ping -c 5 10.0.10.100")
|
|
|
|
# Test hostname resolution over DHCP-provided DNS
|
|
|
|
dhcpConf.wait_until_succeeds("ping -c 5 client.lan")
|
2022-01-17 01:39:27 +01:00
|
|
|
'';
|
|
|
|
}
|