Skip to content

✨ darkone.service.headscale

A full-configured headscale service for HCS.

The tailnet ACL policy is generated from the topology (zones, hosts, users) by dnfLib.mkHeadscalePolicy, validated by headscale policy check at build time, then reloaded on change (SIGHUP) without restarting headscale.

  • Machines are tagged: tag:hcs, tag:gw-<zone>, tag:admin (host whose groups contains admin).
  • Machines and zone LANs reach each other. Personal devices: DNS and HTTPS on the HCS, HTTPS on zone gateways (every zone for admins, else their zone-* groups and the zones of their AI spaces). SSH from admin stations and policy.adminDevices.
  • Every addressed zone host is a policy alias (nas -> its LAN IP): any other service opens through policy.extraAcls (nas:445).
  • Personal devices log in through Kanidm (OIDC), for members of the Kanidm tailnet group; their keys expire after nodeExpiry.
darkone.service.headscale.policy.adminDevices.phone-alice = "100.64.0.9";

Sub-modules (headscale/):

  • dns.nix: unbound, the tailnet pivot DNS, and its tailnet-machines view;
  • audit.nix: headscale-audit, live nodes against the declared topology;
  • enroll.nix: dnf-tailnet-enroll, behind just tailnet-enroll.

unbound on the HCS. Internal names reach it through headscale split DNS; it forwards each zone domain to the zone gateway, the rest to Quad9 over TLS.

View tailnet-machines: tagged nodes (HCS aside) get the zone LAN address of the global services a zone serves (git.<domain> on a gateway), everyone else the public one. unbound-tailnet-view lists their tailnet IPs from headscale, declared nowhere.

headscale-audit, every 15 min: live nodes against the declared topology. Metrics for the dnf-headscale-<zone> alerts, details in its journal. It never tags nor deletes.

dnf-tailnet-enroll, root side of just tailnet-enroll: single-use keys tagged from the declared topology; the enrolled node gets its declared name and tags.

  • enable bool Enable headscale DNF service
  • enableGRPC bool Open GRPC TCP port
  • nodeExpiry str Key expiry of personal devices (0: never). Tagged machines never expire.
  • policy.enforce bool Default-deny tailnet ACLs. false allows all traffic, for a migration only.
  • policy.adminDevices attrs Personal devices granted SSH on every machine and zone: name -> tailnet IPv4.
  • policy.exitNodeSources listOf str Policy sources allowed to use the HCS as exit node.
  • policy.extraHosts attrs Extra policy host aliases (name -> CIDR), to use in extraAcls. Declared zone hosts already have one.
  • policy.extraAcls listOf (attrsOf anything) ACL rules appended after the generated ones.
  • shared raw Headscale values shared with the headscale/ sub-modules.
darkone.service.headscale = {
enable = false;
enableGRPC = false;
nodeExpiry = "180d";
policy.enforce = true;
policy.adminDevices = { };
policy.exitNodeSources = [ ];
policy.extraHosts = { };
policy.extraAcls = [ ];
shared = {
inherit
policy
auditSpec
idmUrl
hcsTailnetIpv4
;
};
};

Source: modules/service/headscale.nix 🡕