config/modules/services/headscale/default.nix

56 lines
1.3 KiB
Nix
Raw Normal View History

2023-08-24 20:44:18 +00:00
{
config,
lib,
pkgs,
...
2024-07-29 12:39:54 +00:00
}:
{
2023-08-24 20:44:18 +00:00
options.mj.services.headscale = with lib.types; {
enable = lib.mkEnableOption "Enable headscale";
2024-07-29 12:39:54 +00:00
subnetCIDR = lib.mkOption { type = str; };
2023-08-24 20:44:18 +00:00
};
config = lib.mkIf config.mj.services.headscale.enable {
2024-07-29 12:39:54 +00:00
environment.systemPackages = [ pkgs.headscale ];
2023-08-24 20:44:18 +00:00
2024-08-02 11:01:04 +00:00
networking.firewall.allowedTCPPorts = [
3478
8080
];
2024-07-29 12:39:54 +00:00
networking.firewall.allowedUDPPorts = [ 3478 ];
2023-08-24 20:44:18 +00:00
services = {
headscale = {
enable = true;
2024-08-02 10:45:25 +00:00
address = "0.0.0.0";
2023-08-24 20:44:18 +00:00
settings = {
server_url = "https://vpn.jakstys.lt";
2024-07-29 12:39:54 +00:00
ip_prefixes = [ config.mj.services.headscale.subnetCIDR ];
2024-11-20 19:13:39 +00:00
prefixes.v4 = config.mj.services.headscale.subnetCIDR;
2023-08-24 20:44:18 +00:00
log.level = "warn";
dns = {
nameservers.global = [
2024-07-29 12:39:54 +00:00
"1.1.1.1"
"8.8.4.4"
];
2023-08-24 20:44:18 +00:00
magic_dns = false;
# https://github.com/juanfont/headscale/issues/2210
base_domain = "jakst.vpn";
2023-08-24 20:44:18 +00:00
};
};
};
};
systemd.services.headscale = {
unitConfig.StartLimitIntervalSec = "5m";
# Allow restarts for up to a minute. A start
# itself may take a while, thus the window of restart
# is higher.
unitConfig.StartLimitBurst = 50;
serviceConfig.RestartSec = 1;
};
};
}