{config, pkgs, lib, ...}:
let
  tailUser = "server";
in {
  imports = [
    ../modules/headscale.nix
  ];
  services.headscale.ensureUsers = {
    "${tailUser}" = {};
  };
  services.tailscale = {
    enable = true;
    extraUpFlags = ["--login-server" "${config.services.headscale.settings.server_url}"];
    authKeyFile = config.services.headscale.ensureUsers."${tailUser}".path;
  };
}
