1 import ./make-test-python.nix ({ pkgs, lib, ... }:
4 pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
6 -x509 -newkey rsa:4096 -sha256 -days 365 \
7 -nodes -out cert.pem -keyout key.pem \
8 -subj '/CN=headscale' -addext "subjectAltName=DNS:headscale"
11 cp key.pem cert.pem $out
15 meta.maintainers = with lib.maintainers; [ misterio77 ];
21 services.tailscale.enable = true;
22 security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
34 server_url = "https://headscale";
35 ip_prefixes = [ "100.64.0.0/10" ];
39 stun_listen_addr = "0.0.0.0:${toString stunPort}";
45 virtualHosts.headscale = {
47 sslCertificate = "${tls-cert}/cert.pem";
48 sslCertificateKey = "${tls-cert}/key.pem";
50 proxyPass = "http://127.0.0.1:${toString headscalePort}";
51 proxyWebsockets = true;
56 networking.firewall = {
57 allowedTCPPorts = [ 80 443 ];
58 allowedUDPPorts = [ stunPort ];
60 environment.systemPackages = [ pkgs.headscale ];
66 headscale.wait_for_unit("headscale")
67 headscale.wait_for_open_port(443)
69 # Create headscale user and preauth-key
70 headscale.succeed("headscale users create test")
71 authkey = headscale.succeed("headscale preauthkeys -u test create --reusable")
74 up_cmd = f"tailscale up --login-server 'https://headscale' --auth-key {authkey}"
78 # Check that they are reachable from the tailnet
79 peer1.wait_until_succeeds("tailscale ping peer2")
80 peer2.wait_until_succeeds("tailscale ping peer1")