nicks-nix-config/hosts/Alaska/modules/headscale.nix

45 lines
1.1 KiB
Nix
Raw Normal View History

2023-12-03 14:07:13 -08:00
{ config, headscale, ... }:
2023-08-05 09:56:57 -07:00
let
2023-10-15 16:35:06 -07:00
tailscale_dns_entries = import ./dns.nix;
2023-08-05 09:56:57 -07:00
baseDomain = "nickiel.net";
domain = "headscale.${baseDomain}";
in {
boot.kernel.sysctl."net.ipv4.ip_forward" = 1;
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
2023-11-01 19:59:59 -07:00
# open for DERP
networking.firewall.allowedUDPPorts = [ 3478 ];
# https://carjorvaz.com/posts/setting-up-headscale-on-nixos/
2023-08-05 09:56:57 -07:00
services.headscale = {
2023-12-03 14:07:13 -08:00
package = headscale.packages."x86_64-linux".headscale;
2023-08-05 09:56:57 -07:00
enable = true;
address = "0.0.0.0";
port = 8082;
settings = {
server_url = "https://${domain}";
2023-10-15 16:35:06 -07:00
dns_config = {
base_domain = baseDomain;
extra_records = tailscale_dns_entries;
};
derp = {
auto_update_enable = true;
update_frequency = "24h";
};
2023-08-05 09:56:57 -07:00
};
};
environment.systemPackages = [ config.services.headscale.package ];
services.nginx.virtualHosts = {
"headscale.nickiel.net" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://127.0.0.1:${ toString config.services.headscale.port }";
proxyWebsockets = true;
};
};
};
2023-08-05 09:56:57 -07:00
}