Commit Graph
5189 Commits
Author SHA1 Message Date
Kristoffer Dalby d4d2017271 derp/server: return STUN bind errors to Serve
log.Fatal exited the process and skipped the graceful shutdown.

Fixes #3499
2026-11-11 16:05:26 +01:00
Kristoffer Dalby 8f47d2a9ad hscontrol: stop Serve through its context
Serve only stopped on signals; a failed listener left it half running.

Updates #3499
2026-11-11 16:05:26 +01:00
Kristoffer Dalby 3e23f167c9 flake: update vendor hash for stunserver import
Updates #3573
2026-11-11 16:05:22 +01:00
Kristoffer Dalby dd4a0edab8 derp/server: serve STUN with Tailscale's stunserver
Own loop answered IPv4 clients of a dual-stack socket with ::ffff:a.b.c.d.

Fixes #3573
2026-11-11 16:05:22 +01:00
Kristoffer Dalby 492c28f5bb .github: run vouch as the headscale-bot App
GITHUB_TOKEN PRs wait for CI approval and cannot merge past main's
rules; the App is the ruleset bypass actor. Sync checks out main, so a
dispatch on another branch cannot squash that branch into main.
2026-11-11 15:19:25 +01:00
Kristoffer Dalby 38da2a9625 .github: open version bump PRs as the headscale-bot App
Juan's PAT authored the PR, so he could not approve it.
2026-11-11 15:19:25 +01:00
Kristoffer Dalby 727024ec52 tools/bump: hand publishing off to a separate step
Lets the gate run without a write token, and the token that
publishes be minted after a gate that can outlive it.
2026-11-11 15:19:25 +01:00
Kristoffer Dalby d2dc13696a config, cli, packaging, nix: stop restarting headscale on a configuration error
serve exits 78 (EX_CONFIG) when the configuration file it loaded is
wrong: format, syntax, keys or values. No file, an unreadable one, the
database and ports still exit 1, so systemd keeps retrying what can
heal. The deb unit and the NixOS module set RestartPreventExitStatus=78.
A parse error gives a position and fixed words, never the file's text.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby a23ea307df packaging: start headscale only with a configuration it accepts
postinst starts or restarts headscale only when check config passes.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 4e8ddfef25 nix: keep only distro facts as module defaults
State paths, socket and disable_check_updates; headscale's defaults cover
the rest. headscale-docker gains a CA bundle to fetch HTTPS DERP maps.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 6247fc59e5 nix, docs: regenerate NixOS options and the configuration reference
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby b600c1f391 cli: print only the required keys with generate config --minimal
With every other key defaulted, server_url alone is a configuration.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 86129dd5ce servertest: start a server from a loaded configuration
NewServerFromConfig serves a config unchanged; TestServerURLOnly proves a
server_url-only file or env config serves both ranges, tailnet.internal
and no DNS resolvers.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby f5f86e69d0 config: require listen_addr and the sqlite path
Empty values serve cannot use; empty server_url reads "is required".

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 2db863d5e6 config: clear a key from the environment with ""
A HEADSCALE_* value of "" means what key: "" means in a file, errors
included, so an env-only setup can clear a defaulted key. An empty
variable still counts as unset.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 542fe8dd55 config: give every key but server_url a working default
server_url alone, in a file or HEADSCALE_SERVER_URL, now passes check config.

Fixes #3567
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 57a18b8c41 hscontrol: refresh the DERP map without blocking other scheduled tasks
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby fcb1d42b86 nix: check the configuration while building the system
check.config also runs `check config -f` on the generated file at build
time, native only, under the unit's environment.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 3a35f74873 nix: build the module on the generated options
settings mirrors headscale's keys one to one, headscale's checks judge the
rest, and the local CLI gets the socket from a variable instead of a file.

headscale always runs as headscale:headscale, which the module creates;
user and group are read-only, so setting either fails evaluation, and stay
only because nixpkgs' headplane module reads them. A settings.cli key
fails evaluation instead of being dropped with a warning, and the unit no
longer gets CAP_CHOWN.
nix/example-configuration.nix goes: the options carry its examples and
defaults.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby cf8362e1a9 config: pin what the NixOS module writes for a minimal configuration
The module is about to move to the generated options; this frozen output
is what its effective configuration must still load to.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby afa16d056e nix, docs: regenerate NixOS options and the configuration reference
Read-only file options take Nix paths; key and state file options take
only absolute paths outside the Nix store; DNS records pass unknown
fields; db_password_file and dns.split appear as removed keys.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby f0a4f6ca67 config: let NixOS DNS records pass unknown fields to headscale
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby c7d097d65e config: log a missing config file only for serve
The environment alone is a complete configuration and client commands
need a file only for an API key, so the loader stops warning; serve logs
at info level that it runs on defaults and the environment.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 69a9bb3e88 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
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 98e9559a57 config: let NixOS options for read-only files take Nix paths
A nix:"path" tag types policy.path, dns.extra_records_path and
tls.cert_path as an absolute path or "", and derp.paths as a list of
paths, so pkgs.writeText and ./policy.hujson work. A nix:"external" tag
types key and state files as an absolute path outside the Nix store, so
no private key is copied into the world-readable store.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 0844b7649d nix: check the policy at build time and the config before a switch
Store-path policy: check policy -f in system.checks.
Pre-switch: check all as the headscale user.
Adapted: no file: secret warning; groups as after activation; a new primary
group skips; the policy the unit's env selects; docs say which check covers
the policy; VM case for the unit's env.

(cherry picked from commit b6ba6e42ee)

Fixes #2898
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby fe908c2d5a goreleaser: generate shipped config files, remove config-example.yaml
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 42a74821bc docs: add generated configuration reference and example
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby ea5e6893a3 config: generate the configuration reference
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 8405c248e1 nix: add generated NixOS options
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby d437b271ce cli: generate NixOS options from the config schema
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 6602227d3e cli: add generate config, replacing dumpConfig
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby f7f1d91d0f gen/client/v1: regenerate for the running configuration endpoint
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 59ebffd64a api: serve the running configuration
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 92ccd62eb1 config: render the example configuration
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby a2e5e36ab2 config: describe every key for the generators
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 2aab876be8 types: generate a table of config field docs
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 90de2ed00d config: keep every default in Default
The DNS-01 challenge resolvers, dns.challenge.resolvers, now default to
Quad9 (9.9.9.9:53, 149.112.112.112:53) instead of Cloudflare and
Google.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby d835c9c6bf types: document every config field
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby e9abc6ae35 hscontrol: validate configuration in NewHeadscale
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 4dbf981679 config: make the loaded configuration round-trip
Configuration keys now match only as written, in lower case. BREAKING:
Server_URL is an unknown key, where 0.29 and the previous commits
ignored case. Each key has one spelling, the one the dump prints.
Open-map entry names keep their own rule: split DNS domains and
provider settings are lowercased, oidc.extra_params keeps case.

Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby f1cbdcfacb config: load configuration outside types
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 890adee7fa types: decode configuration strictly
Fixes #2899
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 865c001068 types: give config values their own types
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 77491a5bd8 types: compute derived config values where they are used
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 3e12fa9d39 types: remove viper
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby cb4ccd97c2 types: reject unknown and removed config keys
Fixes #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 7328157817 types: load configuration with koanf
Updates #1926
2026-11-11 15:02:16 +01:00
Kristoffer Dalby 443f3a0ecd types: pin effective config of shipped examples
Updates #1926
2026-11-11 12:19:23 +01:00
Kristoffer Dalby 167f4f646f prek: run treefmt hook serially
Parallel nix fmt batches time out on treefmt's cache lock.

Updates #1926
2026-11-11 12:19:23 +01:00