2023-11-28 21:43:26 -05:00
|
|
|
{
|
2024-01-09 14:49:05 -05:00
|
|
|
config,
|
2023-11-28 21:43:26 -05:00
|
|
|
headscale,
|
2024-01-09 14:49:05 -05:00
|
|
|
lib,
|
2023-11-28 21:43:26 -05:00
|
|
|
pkgs,
|
|
|
|
...
|
2023-11-29 22:14:29 -05:00
|
|
|
}: let
|
2024-01-22 11:09:37 -05:00
|
|
|
inherit (builtins) readFile;
|
2024-01-23 23:42:41 -05:00
|
|
|
inherit (config.vars) mainUser hostName;
|
2023-11-29 22:14:29 -05:00
|
|
|
headscale-flake = headscale.packages.${pkgs.system}.headscale;
|
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 {
|
|
|
|
environment.systemPackages = [headscale-flake];
|
2024-01-09 13:13:04 -05:00
|
|
|
users.users.${mainUser}.extraGroups = ["headscale"];
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-01-09 14:49:05 -05:00
|
|
|
home-manager.users.${mainUser}
|
2024-01-22 11:09:37 -05:00
|
|
|
.programs.bash.bashrcExtra = lib.mkAfter (readFile ./completion.bash);
|
2024-01-09 14:49:05 -05:00
|
|
|
|
2023-11-28 21:43:26 -05:00
|
|
|
services.headscale = {
|
|
|
|
enable = true;
|
2023-11-29 22:14:29 -05:00
|
|
|
package = headscale-flake;
|
2023-11-28 21:43:26 -05:00
|
|
|
|
2024-01-23 23:42:41 -05:00
|
|
|
address = clusterIP;
|
2023-11-28 21:43:26 -05:00
|
|
|
port = 8085;
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
server_url = "https://headscale.nelim.org";
|
|
|
|
ip_prefixes = ["100.64.0.0/10"];
|
|
|
|
metrics_listen_addr = "127.0.0.1:9090";
|
|
|
|
grpc_listen_addr = "0.0.0.0:50443";
|
|
|
|
grpc_allow_insecure = false;
|
|
|
|
disable_check_updates = true;
|
2023-12-20 22:01:29 -05:00
|
|
|
unix_socket_permission = "0770";
|
2023-11-28 21:43:26 -05:00
|
|
|
|
|
|
|
db_type = "sqlite3";
|
|
|
|
db_path = "/var/lib/headscale/db.sqlite";
|
|
|
|
private_key_path = "/var/lib/headscale/private.key";
|
|
|
|
noise.private_key_path = "/var/lib/headscale/noise_private.key";
|
|
|
|
|
2024-01-23 23:42:41 -05:00
|
|
|
dns_config = let
|
|
|
|
caddyIp =
|
|
|
|
if hostName == "thingone"
|
|
|
|
then "100.64.0.8"
|
|
|
|
else "100.64.0.9";
|
|
|
|
in {
|
2023-11-28 21:43:26 -05:00
|
|
|
magic_dns = false;
|
|
|
|
override_local_dns = true;
|
2024-01-23 23:42:41 -05:00
|
|
|
nameservers = [caddyIp];
|
2023-11-28 21:43:26 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
derp = {
|
|
|
|
urls = [];
|
|
|
|
|
|
|
|
server = {
|
|
|
|
enabled = true;
|
2024-01-23 23:42:41 -05:00
|
|
|
stun_listen_addr = "${clusterIP}:3479";
|
2023-11-28 21:43:26 -05:00
|
|
|
private_key_path = "/var/lib/headscale/derp_server_private.key";
|
|
|
|
|
|
|
|
region_id = 995;
|
|
|
|
region_code = "mon";
|
|
|
|
region_name = "montreal";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|