1
0
Fork 0
dotfiles/system/nixos/headscale.nix

79 lines
1.6 KiB
Nix
Raw Permalink Normal View History

{ pkgs, config, ... }:
let
fqdn = "ctrl.headscale.kempkens.network";
in
{
environment.systemPackages = [ pkgs.headscale ];
2023-11-19 16:58:39 +00:00
services = {
headscale = {
enable = true;
2023-11-19 16:58:39 +00:00
address = "127.0.0.1";
port = 8017;
2023-11-19 16:58:39 +00:00
settings = {
ip_prefixes = [
"fd7a:115c:a1e0:1010::/64"
"100.64.10.0/24"
];
2023-11-19 16:58:39 +00:00
db_type = "postgres";
db_host = "/run/postgresql";
db_name = "headscale";
db_user = "headscale";
db_password_file = config.age.secrets.headscale-database-password.path;
2023-11-19 16:58:39 +00:00
server_url = "https://${fqdn}";
acl_policy_path = config.age.secrets.headscale-acls.path;
2023-09-22 21:59:48 +00:00
2023-11-19 16:58:39 +00:00
dns_config = {
2024-05-25 13:47:17 +00:00
override_local_dns = true;
2023-09-22 21:59:48 +00:00
2023-11-19 16:58:39 +00:00
nameservers = [
"100.64.10.1"
"100.64.10.6"
];
2023-09-22 21:59:48 +00:00
2023-11-19 16:58:39 +00:00
base_domain = "mesh.kempkens.network";
};
2023-09-22 21:59:48 +00:00
};
};
2023-11-19 16:58:39 +00:00
postgresql = {
ensureDatabases = [ "headscale" ];
2023-11-19 16:58:39 +00:00
ensureUsers = [
{
name = "headscale";
ensureDBOwnership = true;
2023-11-19 16:58:39 +00:00
}
];
};
2023-11-19 16:58:39 +00:00
nginx.virtualHosts."${fqdn}" = {
quic = true;
http3 = true;
2023-11-19 16:58:39 +00:00
onlySSL = true;
useACMEHost = "headscale.kempkens.network";
2023-11-19 16:58:39 +00:00
extraConfig = ''
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
'';
2023-11-19 16:58:39 +00:00
locations."/" = {
recommendedProxySettings = true;
proxyPass = "http://127.0.0.1:8017";
proxyWebsockets = true;
};
2023-11-19 16:58:39 +00:00
locations."/web" = {
root = "${pkgs.headscale-ui}/share";
};
};
};
2023-11-19 16:58:39 +00:00
systemd.services.tailscaled.after = [ "headscale.service" ];
}