From 6db6129b6253eeac3652bfcb942c7fcf744bd4e5 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 8 Nov 2026 23:52:28 +0000 Subject: [PATCH] config: let NixOS DNS records pass unknown fields to headscale Updates #1926 --- hscontrol/config/nixos.go | 4 +++- hscontrol/config/nixos_test.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hscontrol/config/nixos.go b/hscontrol/config/nixos.go index 0b33a86b0..0b2d4cbd9 100644 --- a/hscontrol/config/nixos.go +++ b/hscontrol/config/nixos.go @@ -159,7 +159,9 @@ func nixOption(k keyInfo, indent int) (string, error) { fmt.Fprintf(&fields, "%s%s = %s;\n", pad, f.Name, mkOption(in+6, attrs)) } - typ = fmt.Sprintf("lib.types.listOf (\n%[1]s lib.types.submodule {\n%[1]s options = {\n%[2]s%[1]s };\n%[1]s }\n%[1]s)", + // Freeform, so an unknown field reaches headscale, whose check names + // it, instead of failing evaluation. + typ = fmt.Sprintf("lib.types.listOf (\n%[1]s lib.types.submodule {\n%[1]s freeformType = lib.types.attrsOf lib.types.anything;\n%[1]s options = {\n%[2]s%[1]s };\n%[1]s }\n%[1]s)", strings.Repeat(" ", in), fields.String()) default: return "", fmt.Errorf("%w for %s", errNoNixType, k.Field.Type) diff --git a/hscontrol/config/nixos_test.go b/hscontrol/config/nixos_test.go index 7d418aed0..0ac42da01 100644 --- a/hscontrol/config/nixos_test.go +++ b/hscontrol/config/nixos_test.go @@ -217,7 +217,8 @@ func TestGenerateNixOptions(t *testing.T) { { path: "dns.extra_records", want: []string{ - "\n type = lib.types.listOf (\n lib.types.submodule {\n options = {\n name = lib.mkOption {\n", + // An unknown field reaches headscale's check, not a Nix error. + "\n type = lib.types.listOf (\n lib.types.submodule {\n freeformType = lib.types.attrsOf lib.types.anything;\n options = {\n name = lib.mkOption {\n", "\n default = [ ];\n", }, },