mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 03:17:13 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
91 lines
2.6 KiB
Nix
91 lines
2.6 KiB
Nix
import ./make-test-python.nix (
|
|
{ pkgs, lib, ... }:
|
|
let
|
|
tls-cert = pkgs.runCommand "selfSignedCerts" { buildInputs = [ pkgs.openssl ]; } ''
|
|
openssl req \
|
|
-x509 -newkey rsa:4096 -sha256 -days 365 \
|
|
-nodes -out cert.pem -keyout key.pem \
|
|
-subj '/CN=headscale' -addext "subjectAltName=DNS:headscale"
|
|
|
|
mkdir -p $out
|
|
cp key.pem cert.pem $out
|
|
'';
|
|
in
|
|
{
|
|
name = "headscale";
|
|
meta.maintainers = with lib.maintainers; [ misterio77 ];
|
|
|
|
nodes =
|
|
let
|
|
headscalePort = 8080;
|
|
stunPort = 3478;
|
|
peer = {
|
|
services.tailscale.enable = true;
|
|
security.pki.certificateFiles = [ "${tls-cert}/cert.pem" ];
|
|
};
|
|
in
|
|
{
|
|
peer1 = peer;
|
|
peer2 = peer;
|
|
|
|
headscale = {
|
|
services = {
|
|
headscale = {
|
|
enable = true;
|
|
port = headscalePort;
|
|
settings = {
|
|
server_url = "https://headscale";
|
|
ip_prefixes = [ "100.64.0.0/10" ];
|
|
derp.server = {
|
|
enabled = true;
|
|
region_id = 999;
|
|
stun_listen_addr = "0.0.0.0:${toString stunPort}";
|
|
};
|
|
dns.base_domain = "tailnet";
|
|
};
|
|
};
|
|
nginx = {
|
|
enable = true;
|
|
virtualHosts.headscale = {
|
|
addSSL = true;
|
|
sslCertificate = "${tls-cert}/cert.pem";
|
|
sslCertificateKey = "${tls-cert}/key.pem";
|
|
locations."/" = {
|
|
proxyPass = "http://127.0.0.1:${toString headscalePort}";
|
|
proxyWebsockets = true;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
networking.firewall = {
|
|
allowedTCPPorts = [
|
|
80
|
|
443
|
|
];
|
|
allowedUDPPorts = [ stunPort ];
|
|
};
|
|
environment.systemPackages = [ pkgs.headscale ];
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
headscale.wait_for_unit("headscale")
|
|
headscale.wait_for_open_port(443)
|
|
|
|
# Create headscale user and preauth-key
|
|
headscale.succeed("headscale users create test")
|
|
authkey = headscale.succeed("headscale preauthkeys -u test create --reusable")
|
|
|
|
# Connect peers
|
|
up_cmd = f"tailscale up --login-server 'https://headscale' --auth-key {authkey}"
|
|
peer1.execute(up_cmd)
|
|
peer2.execute(up_cmd)
|
|
|
|
# Check that they are reachable from the tailnet
|
|
peer1.wait_until_succeeds("tailscale ping peer2")
|
|
peer2.wait_until_succeeds("tailscale ping peer1.tailnet")
|
|
'';
|
|
}
|
|
)
|