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", }, },