2024-01-09 18:47:47 -08:00
|
|
|
{ config, pkgs, headscale, ... }:
|
2023-08-05 09:56:57 -07:00
|
|
|
|
|
|
|
let
|
2023-10-15 16:35:06 -07:00
|
|
|
tailscale_dns_entries = import ./dns.nix;
|
2024-10-09 17:21:23 -07:00
|
|
|
baseDomain = "tailscale.nickiel.net";
|
|
|
|
domain = "headscale.nickiel.net";
|
2023-08-05 09:56:57 -07:00
|
|
|
in {
|
2024-01-06 19:59:12 -08:00
|
|
|
# headscale routes list
|
|
|
|
# headscale routes enable -r NUMBER
|
|
|
|
# to enable exit node to be used
|
2023-08-07 15:35:21 -07:00
|
|
|
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 ];
|
|
|
|
|
2023-08-05 10:03:18 -07:00
|
|
|
# https://carjorvaz.com/posts/setting-up-headscale-on-nixos/
|
2023-08-05 09:56:57 -07:00
|
|
|
services.headscale = {
|
2024-01-09 18:47:47 -08:00
|
|
|
package = headscale.packages.${pkgs.system}.headscale;
|
2023-08-05 09:56:57 -07:00
|
|
|
enable = true;
|
|
|
|
address = "0.0.0.0";
|
|
|
|
port = 8082;
|
|
|
|
settings = {
|
2024-04-19 18:46:00 -07:00
|
|
|
prefixes = {
|
|
|
|
v6 = "fd7a:115c:a1e0::/48";
|
|
|
|
v4 = "100.64.0.0/10";
|
|
|
|
};
|
2023-08-05 09:56:57 -07:00
|
|
|
server_url = "https://${domain}";
|
2024-04-19 18:46:00 -07:00
|
|
|
database = {
|
|
|
|
type = "sqlite3";
|
|
|
|
sqlite.path = "/var/lib/headscale/db.sqlite";
|
|
|
|
};
|
2024-10-09 17:02:53 -07:00
|
|
|
dns = {
|
2023-10-15 16:35:06 -07:00
|
|
|
base_domain = baseDomain;
|
2024-10-09 17:21:23 -07:00
|
|
|
magic_dns = true;
|
2023-10-15 16:35:06 -07:00
|
|
|
extra_records = tailscale_dns_entries;
|
|
|
|
};
|
2023-10-21 16:55:52 -07:00
|
|
|
derp = {
|
|
|
|
auto_update_enable = true;
|
|
|
|
update_frequency = "24h";
|
|
|
|
};
|
2023-08-05 09:56:57 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
environment.systemPackages = [ config.services.headscale.package ];
|
2023-10-21 16:55:52 -07:00
|
|
|
|
|
|
|
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
|
|
|
}
|