2024-09-11 02:26:47 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-09-13 01:50:53 +00:00
|
|
|
with lib; let
|
2024-10-06 15:16:52 +00:00
|
|
|
cfg = config.custom.containers.headscale;
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
2024-10-06 15:16:52 +00:00
|
|
|
options.custom.containers.headscale.enable = mkOption {default = false;};
|
2024-09-11 02:26:47 +00:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-09-13 01:50:53 +00:00
|
|
|
age.secrets = let
|
|
|
|
secret = filename: {
|
|
|
|
file = "${inputs.self}/secrets/${filename}";
|
2024-09-11 02:26:47 +00:00
|
|
|
};
|
2024-09-13 01:50:53 +00:00
|
|
|
in {
|
|
|
|
"${config.custom.profile}/headscale/.env" = secret "${config.custom.profile}/headscale/.env";
|
|
|
|
};
|
2024-09-11 02:26:47 +00:00
|
|
|
|
|
|
|
#?? arion-headscale pull
|
|
|
|
environment.shellAliases.arion-headscale = "sudo arion --prebuilt-file ${config.virtualisation.arion.projects.headscale.settings.out.dockerComposeYaml}";
|
|
|
|
|
|
|
|
virtualisation.arion.projects.headscale = {
|
|
|
|
serviceName = "headscale";
|
|
|
|
|
|
|
|
settings.services = {
|
|
|
|
# https://headscale.net/
|
|
|
|
# https://github.com/juanfont/headscale
|
|
|
|
# BUG: Does not support generic DoH/DoT
|
|
|
|
# https://github.com/juanfont/headscale/issues/1312
|
|
|
|
headscale.service = {
|
|
|
|
command = "serve";
|
|
|
|
container_name = "headscale";
|
2024-09-13 01:50:53 +00:00
|
|
|
env_file = [config.age.secrets."${config.custom.profile}/headscale/.env".path];
|
2024-09-11 02:26:47 +00:00
|
|
|
image = "headscale/headscale:v0.23.0-beta.4";
|
|
|
|
restart = "unless-stopped";
|
|
|
|
|
|
|
|
ports = [
|
|
|
|
"9999:9999"
|
|
|
|
"9090:9090"
|
|
|
|
];
|
|
|
|
|
|
|
|
volumes = [
|
2024-10-06 15:16:52 +00:00
|
|
|
"${config.custom.containers.directory}/headscale/config:/etc/headscale"
|
|
|
|
"${config.custom.containers.directory}/headscale/data:/var/lib/headscale"
|
2024-09-11 02:26:47 +00:00
|
|
|
|
|
|
|
# Minimum config.yaml
|
|
|
|
# https://github.com/juanfont/headscale/blob/main/config-example.yaml
|
|
|
|
# https://github.com/juanfont/headscale/blob/main/integration/hsic/config.go
|
|
|
|
"${pkgs.writeText "config.yaml" ''
|
|
|
|
noise:
|
|
|
|
private_key_path: /var/lib/headscale/noise_private.key
|
|
|
|
''}:/etc/headscale/config.yaml"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|