From 9403ddbf08af1c70516470cddf1cc50a927ea2a2 Mon Sep 17 00:00:00 2001 From: kurogeek Date: Thu, 3 Sep 2026 16:46:51 +0700 Subject: [PATCH] clanService/headscale: adjust magic dns settings --- inventories/default.nix | 27 ++++++++--- modules/clan/headscale/default.nix | 72 +++++++++++++++++++++++------- 2 files changed, 76 insertions(+), 23 deletions(-) diff --git a/inventories/default.nix b/inventories/default.nix index 3499b08..897f605 100644 --- a/inventories/default.nix +++ b/inventories/default.nix @@ -320,13 +320,28 @@ }; roles.server.machines."alasia".settings = { public_url = "tailvpn.public.newedge.house"; - base_domain = "tailnet.newedge.house"; advertise_routes = [ "10.0.10.0/24" ]; - nameservers = [ - "10.0.10.82" - "1.1.1.1" - "8.8.8.8" - ]; + dns = { + magic_dns = true; + base_domain = "tailvpn.newedge.house"; + nameservers = [ + "10.0.10.82" + "1.1.1.1" + "8.8.8.8" + ]; + extra_records = [ + { + name = "poyerp.newedge.house"; + type = "A"; + value = "10.0.10.1"; + } + { + name = "glomerp.newedge.house"; + type = "A"; + value = "10.0.10.1"; + } + ]; + }; }; }; diff --git a/modules/clan/headscale/default.nix b/modules/clan/headscale/default.nix index 1719813..4dbadbe 100644 --- a/modules/clan/headscale/default.nix +++ b/modules/clan/headscale/default.nix @@ -19,12 +19,6 @@ description = "Public URL for accessing the instance"; }; - base_domain = lib.mkOption { - type = with lib.types; str; - default = ""; - description = "Defines the base domain to create the hostnames for MagicDNS in Headscale. `base_domain` must be a FQDN, without the trailing dot. The FQDN of the hosts will be `hostname.base_domain (e.g. myhost.tailnet.example.com)"; - }; - advertise_routes = lib.mkOption { type = with lib.types; listOf str; default = [ ]; @@ -32,14 +26,57 @@ example = [ "192.168.1.0/24" ]; }; - nameservers = lib.mkOption { - type = with lib.types; listOf str; - default = [ - "1.1.1.1" - "8.8.8.8" - ]; - description = "List of nameservers to pass to Tailscale clients"; - example = [ "10.0.10.1" ]; + dns = { + base_domain = lib.mkOption { + type = with lib.types; str; + default = ""; + description = "Defines the base domain to create the hostnames for MagicDNS in Headscale. `base_domain` must be a FQDN, without the trailing dot. The FQDN of the hosts will be `hostname.base_domain (e.g. myhost.tailnet.example.com)"; + }; + + nameservers = lib.mkOption { + type = with lib.types; listOf str; + default = [ + "1.1.1.1" + "8.8.8.8" + ]; + description = "List of nameservers to pass to Tailscale clients"; + example = [ "10.0.10.1" ]; + }; + + magic_dns = lib.mkOption { + type = with lib.types; bool; + default = true; + description = "Whether to enable MagicDNS"; + }; + + extra_records = lib.mkOption { + type = + with lib.types; + nullOr ( + listOf (submodule { + options = { + name = lib.mkOption { + type = lib.types.str; + description = "DNS record name."; + example = "grafana.tailnet.example.com"; + }; + type = lib.mkOption { + type = lib.types.enum [ + "A" + "AAAA" + ]; + description = "DNS record type."; + example = "A"; + }; + value = lib.mkOption { + type = lib.types.str; + description = "DNS record value (IP address)."; + example = "100.64.0.3"; + }; + }; + }) + ); + }; }; }; }; @@ -170,10 +207,11 @@ settings.server_url = "https://${settings.public_url}"; settings.dns = { - base_domain = settings.base_domain; + base_domain = settings.dns.base_domain; override_local_dns = true; - nameservers.global = settings.nameservers; - magic_dns = false; + nameservers.global = settings.dns.nameservers; + magic_dns = settings.dns.magic_dns; + extra_records = settings.dns.extra_records; }; };