2024-11-22 23:15:13 -05:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
mainUser,
|
|
|
|
...
|
|
|
|
}: let
|
2024-11-18 12:30:54 -05:00
|
|
|
inherit (config.networking) hostName;
|
2024-01-23 23:42:41 -05:00
|
|
|
|
2024-02-01 11:48:38 -05:00
|
|
|
clusterIP = config.services.pcsd.virtualIps.caddy-vip.ip;
|
2023-11-29 22:14:29 -05:00
|
|
|
in {
|
2024-04-01 01:50:30 -04:00
|
|
|
users.users.${mainUser}.extraGroups = ["headscale"];
|
2024-01-09 14:49:05 -05:00
|
|
|
|
2024-04-01 01:50:30 -04:00
|
|
|
services.headscale = {
|
|
|
|
enable = true;
|
|
|
|
|
2024-10-10 14:59:38 -04:00
|
|
|
settings = {
|
2024-04-01 01:50:30 -04:00
|
|
|
server_url = "https://headscale.nelim.org";
|
|
|
|
listen_addr = "${clusterIP}:8085";
|
|
|
|
prefixes = {
|
|
|
|
v4 = "100.64.0.0/10";
|
|
|
|
v6 = "fd7a:115c:a1e0::/48";
|
|
|
|
};
|
|
|
|
metrics_listen_addr = "127.0.0.1:9090";
|
|
|
|
grpc_listen_addr = "0.0.0.0:50443";
|
|
|
|
grpc_allow_insecure = false;
|
|
|
|
disable_check_updates = true;
|
|
|
|
ephemeral_node_inactivity_timeout = "30m";
|
|
|
|
unix_socket = "/run/headscale/headscale.sock";
|
|
|
|
unix_socket_permission = "0770";
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-04-01 01:50:30 -04:00
|
|
|
database = {
|
|
|
|
type = "sqlite";
|
|
|
|
sqlite.path = "/var/lib/headscale/db.sqlite";
|
|
|
|
};
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-04-01 01:50:30 -04:00
|
|
|
private_key_path = "/var/lib/headscale/private.key";
|
|
|
|
noise.private_key_path = "/var/lib/headscale/noise_private.key";
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-09-20 23:09:28 -04:00
|
|
|
dns = let
|
2024-04-01 01:50:30 -04:00
|
|
|
caddyIp =
|
|
|
|
if hostName == "thingone"
|
|
|
|
then "100.64.0.8"
|
|
|
|
else "100.64.0.9";
|
|
|
|
in {
|
|
|
|
magic_dns = false;
|
|
|
|
override_local_dns = true;
|
2024-09-20 23:09:28 -04:00
|
|
|
nameservers.global = [caddyIp];
|
2024-04-01 01:50:30 -04:00
|
|
|
};
|
2024-03-31 23:42:49 -04:00
|
|
|
|
2024-04-01 01:50:30 -04:00
|
|
|
log = {
|
|
|
|
format = "text";
|
|
|
|
level = "info";
|
|
|
|
};
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-04-01 01:50:30 -04:00
|
|
|
derp = {
|
|
|
|
auto_update_enable = true;
|
|
|
|
update_frequency = "24h";
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-04-01 01:50:30 -04:00
|
|
|
server = {
|
|
|
|
enabled = true;
|
|
|
|
stun_listen_addr = "${clusterIP}:3479";
|
|
|
|
private_key_path = "/var/lib/headscale/derp_server_private.key";
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-04-01 01:50:30 -04:00
|
|
|
region_id = 995;
|
|
|
|
region_code = "mon";
|
|
|
|
region_name = "montreal";
|
2023-11-28 21:43:26 -05:00
|
|
|
};
|
|
|
|
};
|
2024-10-10 14:59:38 -04:00
|
|
|
};
|
|
|
|
};
|
2023-11-28 21:43:26 -05:00
|
|
|
}
|