From 8c89030d486dc9b3cd3e611c2bfbbb8eff24faae Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sun, 8 Nov 2026 22:52:50 +0000 Subject: [PATCH] config: name the NixOS module's old settings keys as removed db_password_file and dns.split were rejected only by the NixOS module; Go now names their replacements, so the module can drop its list. Updates #1926 --- hscontrol/config/keys.go | 4 ++++ hscontrol/config/load_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/hscontrol/config/keys.go b/hscontrol/config/keys.go index c419e9239..81131a17b 100644 --- a/hscontrol/config/keys.go +++ b/hscontrol/config/keys.go @@ -119,6 +119,8 @@ var removedKeys = []removedKey{ {Old: "dns_config.extra_records", New: "dns.extra_records", Since: "0.30"}, {Old: "dns_config.use_username_in_magic_dns", Since: "0.24"}, {Old: "dns.use_username_in_magic_dns", Since: "0.24"}, + // The NixOS module's name; headscale never read it. + {Old: "dns.split", New: "dns.nameservers.split", Since: "0.30"}, {Old: "oidc.strip_email_domain", Since: "0.26"}, {Old: "oidc.map_legacy_users", Since: "0.26"}, {Old: "randomize_client_port", Since: "0.29", Hint: `set "randomizeClientPort": true at the top level of the policy file, or grant the cap per node via a "nodeAttrs" entry`}, @@ -143,6 +145,8 @@ var removedKeys = []removedKey{ {Old: "db_user", New: "database.postgres.user", Since: "0.30"}, {Old: "db_pass", New: "database.postgres.pass", Since: "0.30"}, {Old: "db_ssl", New: "database.postgres.ssl", Since: "0.30"}, + // The NixOS module's name; headscale never read it. + {Old: "db_password_file", New: "database.postgres.pass", Value: "file:", Since: "0.30"}, {Old: "private_key_path", New: "noise.private_key_path", Since: "0.23"}, {Old: "ip_prefixes", New: "prefixes.v4 prefixes.v6", Since: "0.23"}, {Old: "log_level", New: "log.level", Since: "0.17"}, diff --git a/hscontrol/config/load_test.go b/hscontrol/config/load_test.go index f76218c3c..71047f4fd 100644 --- a/hscontrol/config/load_test.go +++ b/hscontrol/config/load_test.go @@ -1669,6 +1669,7 @@ func TestRemovedKeysAreRejected(t *testing.T) { want []string // substrings of the load error warns []string // substrings of the warnings serverErr string // from Validate after a clean load + check func(t *testing.T, cfg *types.Config) }{ { name: "deprecated keys", @@ -1714,6 +1715,26 @@ func TestRemovedKeysAreRejected(t *testing.T) { env: map[string]string{"HEADSCALE_DATABASE_POSTGRES_PASSWORD_FILE": "/run/secret"}, warns: []string{"HEADSCALE_DATABASE_POSTGRES_PASSWORD_FILE was removed", "use HEADSCALE_DATABASE_POSTGRES_PASS=file:"}, }, + // The old NixOS module's settings, which headscale never read. + { + name: "nixos db password file", + file: "db_password_file: /run/x\n", + want: []string{"db_password_file was removed", `database.postgres.pass: "file:"`}, + }, + { + name: "nixos dns split", + file: "dns:\n split:\n corp: [\"192.0.2.53\"]\n", + want: []string{"dns.split was removed", "use dns.nameservers.split"}, + }, + { + name: "nixos dns split env", + env: map[string]string{"HEADSCALE_DNS_SPLIT": `{"corp":["192.0.2.53"]}`}, + warns: []string{"HEADSCALE_DNS_SPLIT was removed", "use HEADSCALE_DNS_NAMESERVERS_SPLIT"}, + check: func(t *testing.T, cfg *types.Config) { + t.Helper() + assert.Empty(t, cfg.DNSConfig.Nameservers.Split) + }, + }, { name: "env hints name variables", env: map[string]string{ @@ -1910,6 +1931,10 @@ func TestRemovedKeysAreRejected(t *testing.T) { if tt.serverErr != "" { require.ErrorContains(t, Validate(l.Config), tt.serverErr) } + + if tt.check != nil { + tt.check(t, l.Config) + } }) } }