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
This commit is contained in:
Kristoffer Dalby committed 2026-11-11 15:02:16 +01:00
1 parent 98e9559a57
commit 69a9bb3e88
2 files changed
+29

No files matched your search

+4
View File
@@ -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:<path>", 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"},
+25
View File
@@ -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:<path>"},
},
// 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:<path>"`},
},
{
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)
}
})
}
}