From 69181ea51eac2127a482b7ce34ad366e722d8a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Tue, 29 Sep 2026 01:54:02 +0200 Subject: [PATCH 1/2] nixos/adguardhome: drop support for schema version <23 --- .../manual/release-notes/rl-2611.section.md | 2 ++ .../services/networking/adguardhome.nix | 28 ++++++------------- nixos/tests/adguardhome.nix | 12 -------- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2611.section.md b/nixos/doc/manual/release-notes/rl-2611.section.md index c0c9169150de..355c44acb454 100644 --- a/nixos/doc/manual/release-notes/rl-2611.section.md +++ b/nixos/doc/manual/release-notes/rl-2611.section.md @@ -216,6 +216,8 @@ - `ensure-printers.service` has been replaced with an `ExecStartPost` hook in `cups.service`. If you have made any manual modifications to this unit, you should move the modifications to `cups.service` instead. +- `services.adguardhome` no longer supports `settings.schema_version` values below 23. + - The `NIX_XDG_DESKTOP_PORTAL_DIR` environment variable is no longer used in the `xdg-desktop-portal` package and is therefore no longer set in `xdg.portal` module. Instead the `XDG_DATA_DIRS` environment variable is used to find xdg-portals. diff --git a/nixos/modules/services/networking/adguardhome.nix b/nixos/modules/services/networking/adguardhome.nix index 902a4f735b70..51b501f186d7 100644 --- a/nixos/modules/services/networking/adguardhome.nix +++ b/nixos/modules/services/networking/adguardhome.nix @@ -18,21 +18,15 @@ let ++ cfg.extraArgs ); + minimumSchemaVersion = 23; + settings = if (cfg.settings != null) then - lib.recursiveUpdate cfg.settings ( - if cfg.settings.schema_version < 23 then - { - bind_host = cfg.host; - bind_port = cfg.port; - } - else - { - http = (cfg.settings.http or { }) // { - address = "${cfg.host}:${toString cfg.port}"; - }; - } - ) + lib.recursiveUpdate cfg.settings { + http = (cfg.settings.http or { }) // { + address = "${cfg.host}:${toString cfg.port}"; + }; + } else null; @@ -146,12 +140,8 @@ in config = lib.mkIf cfg.enable { assertions = [ { - assertion = cfg.settings != null -> !(lib.hasAttrByPath [ "bind_host" ] cfg.settings); - message = "AdGuard option `settings.bind_host' has been superseded by `services.adguardhome.host'"; - } - { - assertion = cfg.settings != null -> !(lib.hasAttrByPath [ "bind_port" ] cfg.settings); - message = "AdGuard option `settings.bind_port' has been superseded by `services.adguardhome.port'"; + assertion = cfg.settings != null -> cfg.settings.schema_version >= minimumSchemaVersion; + message = "AdGuard option `settings.schema_version' must be at least ${toString minimumSchemaVersion}"; } { assertion = diff --git a/nixos/tests/adguardhome.nix b/nixos/tests/adguardhome.nix index ab115e5db564..e5249c2fafbf 100644 --- a/nixos/tests/adguardhome.nix +++ b/nixos/tests/adguardhome.nix @@ -14,14 +14,6 @@ }; }; - schemaVersionBefore23 = { - services.adguardhome = { - enable = true; - - settings.schema_version = 20; - }; - }; - syslogConf = { services.adguardhome = { enable = true; @@ -131,10 +123,6 @@ 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) - with subtest("Logging to syslog test"): # AdGuard is expected to fail when it cannot connect to syslog # hence its sufficient to look whether the service starts at all From 861f76e48af481d54ccf4701d65304abcab1f04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Mon, 28 Sep 2026 13:41:22 +0200 Subject: [PATCH 2/2] nixos/adguardhome: migrate host and port options to RFC 42-style settings --- .../services/networking/adguardhome.nix | 79 +++++++++++++------ nixos/tests/adguardhome.nix | 19 ++++- 2 files changed, 70 insertions(+), 28 deletions(-) diff --git a/nixos/modules/services/networking/adguardhome.nix b/nixos/modules/services/networking/adguardhome.nix index 51b501f186d7..01fa8b0226e7 100644 --- a/nixos/modules/services/networking/adguardhome.nix +++ b/nixos/modules/services/networking/adguardhome.nix @@ -1,13 +1,18 @@ { config, + options, lib, pkgs, ... }: let cfg = config.services.adguardhome; + opt = options.services.adguardhome; settingsFormat = pkgs.formats.yaml { }; + defaultHost = "0.0.0.0"; + defaultPort = 3000; + args = lib.concatStringsSep " " ( [ "--no-check-update" @@ -20,17 +25,13 @@ let minimumSchemaVersion = 23; - settings = - if (cfg.settings != null) then - lib.recursiveUpdate cfg.settings { - http = (cfg.settings.http or { }) // { - address = "${cfg.host}:${toString cfg.port}"; - }; - } + webPort = + if cfg.settings != null then + lib.toInt (lib.last (lib.splitString ":" cfg.settings.http.address)) else - null; + defaultPort; - configFile = (settingsFormat.generate "AdGuardHome.yaml" settings).overrideAttrs (_: { + configFile = (settingsFormat.generate "AdGuardHome.yaml" cfg.settings).overrideAttrs (_: { checkPhase = "${cfg.package}/bin/AdGuardHome -c $out --check-config"; }); in @@ -57,7 +58,7 @@ in }; allowDHCP = lib.mkOption { - default = settings.dhcp.enabled or false; + default = cfg.settings.dhcp.enabled or false; defaultText = lib.literalExpression "config.services.adguardhome.settings.dhcp.enabled or false"; type = bool; description = '' @@ -79,20 +80,16 @@ in ''; }; + # deprecated in favor of `settings.http.address` host = lib.mkOption { - default = "0.0.0.0"; - type = str; - description = '' - Host address to bind HTTP server to. - ''; + type = nullOr str; + default = null; + visible = false; }; - port = lib.mkOption { - default = 3000; - type = port; - description = '' - Port to serve HTTP pages on. - ''; + type = nullOr port; + default = null; + visible = false; }; settings = lib.mkOption { @@ -109,6 +106,14 @@ in Defaults to the `schema_version` supplied by `cfg.package`. ''; }; + + http.address = lib.mkOption { + default = "${defaultHost}:${toString defaultPort}"; + type = str; + description = '' + Address to serve the web interface on, in the `host:port` format. + ''; + }; }; }); description = '' @@ -138,6 +143,25 @@ in }; config = lib.mkIf cfg.enable { + warnings = + lib.concatMap + ( + name: + lib.optional (cfg.${name} != null) '' + The option `services.adguardhome.${name}' defined in ${ + lib.showFiles opt.${name}.files + } is deprecated, set `services.adguardhome.settings.http.address' instead. + '' + ) + [ + "host" + "port" + ]; + + services.adguardhome.settings = lib.mkIf (cfg.host != null || cfg.port != null) { + http.address = "${lib.defaultTo defaultHost cfg.host}:${toString (lib.defaultTo defaultPort cfg.port)}"; + }; + assertions = [ { assertion = cfg.settings != null -> cfg.settings.schema_version >= minimumSchemaVersion; @@ -145,15 +169,18 @@ in } { assertion = - settings != null -> cfg.mutableSettings || lib.hasAttrByPath [ "dns" "bootstrap_dns" ] settings; + cfg.settings != null + -> cfg.mutableSettings || lib.hasAttrByPath [ "dns" "bootstrap_dns" ] cfg.settings; message = "AdGuard setting dns.bootstrap_dns needs to be configured for a minimal working configuration"; } { assertion = - settings != null + cfg.settings != null -> cfg.mutableSettings - || lib.hasAttrByPath [ "dns" "bootstrap_dns" ] settings && lib.isList settings.dns.bootstrap_dns; + || + lib.hasAttrByPath [ "dns" "bootstrap_dns" ] cfg.settings + && lib.isList cfg.settings.dns.bootstrap_dns; message = "AdGuard setting dns.bootstrap_dns needs to be a list"; } ]; @@ -174,7 +201,7 @@ in chmod 600 "$STATE_DIRECTORY/AdGuardHome.yaml" ''; in - lib.optionalString (settings != null) ( + lib.optionalString (cfg.settings != null) ( if cfg.mutableSettings then '' if [ -e "$STATE_DIRECTORY/AdGuardHome.yaml" ]; then @@ -239,6 +266,6 @@ in }; }; - networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ]; + networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ webPort ]; }; } diff --git a/nixos/tests/adguardhome.nix b/nixos/tests/adguardhome.nix index e5249c2fafbf..37d436a5fc91 100644 --- a/nixos/tests/adguardhome.nix +++ b/nixos/tests/adguardhome.nix @@ -14,6 +14,15 @@ }; }; + deprecatedHostPortConf = { + services.adguardhome = { + enable = true; + + host = "127.0.0.1"; + port = 12345; + }; + }; + syslogConf = { services.adguardhome = { enable = true; @@ -26,12 +35,11 @@ services.adguardhome = { enable = true; - host = "127.0.0.1"; mutableSettings = false; - port = 43074; settings = { dns.bootstrap_dns = [ "127.0.0.1" ]; http.doh.insecure_enabled = true; + http.address = "127.0.0.1:43074"; }; }; }; @@ -123,6 +131,13 @@ emptyConf.wait_for_unit("adguardhome.service") emptyConf.wait_for_open_port(3000) + with subtest("Only setting the deprecated port option works"): + deprecatedHostPortConf.wait_for_unit("adguardhome.service") + deprecatedHostPortConf.wait_for_open_port(12345) + deprecatedHostPortConf.succeed( + "grep -qFx ' address: 127.0.0.1:12345' /var/lib/AdGuardHome/AdGuardHome.yaml" + ) + with subtest("Logging to syslog test"): # AdGuard is expected to fail when it cannot connect to syslog # hence its sufficient to look whether the service starts at all