1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 installShellFiles,
6 iana-etc,
7 libredirect,
8 nixosTests,
9 postgresql,
10 stdenv,
11}:
12buildGoModule rec {
13 pname = "headscale";
14 version = "0.26.1";
15
16 src = fetchFromGitHub {
17 owner = "juanfont";
18 repo = "headscale";
19 tag = "v${version}";
20 hash = "sha256-LnS6K3U4RgRRV4i92zcRZtLJF1QdbORQP9ZIis9u6rk=";
21 };
22
23 vendorHash = "sha256-dR8xmUIDMIy08lhm7r95GNNMAbXv4qSH3v9HR40HlNk=";
24
25 subPackages = [ "cmd/headscale" ];
26
27 ldflags = [
28 "-s"
29 "-w"
30 "-X github.com/juanfont/headscale/cmd/headscale/cli.Version=v${version}"
31 ];
32
33 nativeBuildInputs = [ installShellFiles ];
34
35 nativeCheckInputs = [
36 libredirect.hook
37 postgresql
38 ];
39
40 checkFlags = [ "-short" ];
41
42 preCheck = lib.optionalString stdenv.hostPlatform.isDarwin ''
43 export NIX_REDIRECTS=/etc/protocols=${iana-etc}/etc/protocols:/etc/services=${iana-etc}/etc/services
44 '';
45
46 postInstall = ''
47 installShellCompletion --cmd headscale \
48 --bash <($out/bin/headscale completion bash) \
49 --fish <($out/bin/headscale completion fish) \
50 --zsh <($out/bin/headscale completion zsh)
51 '';
52
53 passthru.tests = { inherit (nixosTests) headscale; };
54
55 meta = with lib; {
56 homepage = "https://github.com/juanfont/headscale";
57 description = "Open source, self-hosted implementation of the Tailscale control server";
58 longDescription = ''
59 Tailscale is a modern VPN built on top of Wireguard. It works like an
60 overlay network between the computers of your networks - using all kinds
61 of NAT traversal sorcery.
62
63 Everything in Tailscale is Open Source, except the GUI clients for
64 proprietary OS (Windows and macOS/iOS), and the
65 'coordination/control server'.
66
67 The control server works as an exchange point of Wireguard public keys for
68 the nodes in the Tailscale network. It also assigns the IP addresses of
69 the clients, creates the boundaries between each user, enables sharing
70 machines between users, and exposes the advertised routes of your nodes.
71
72 Headscale implements this coordination server.
73 '';
74 license = licenses.bsd3;
75 mainProgram = "headscale";
76 maintainers = with maintainers; [
77 kradalby
78 misterio77
79 ];
80 };
81}