nixpkgs-suyu/pkgs/servers/tailscale/default.nix
Danielle Lancashire 7526ae55d7
tailscale: Include version in build flags
This commit adds the user-facing version to the tailscale version
output.

Prior to this change, it used a hardcoded fallback that is fairly
infrequently updated (https://github.com/tailscale/tailscale/commits/main/version/version.go).

After this change, we print the user-friendlier tag version, which is
helpful when wanting to e.g check to see if you have a version that is
compatible with a feature like [magic dns][magic-dns].

E.g:

```
[nixpkgs(dani/tailscale-version)] $ ./result/bin/tailscale version
1.0.5
```

[magic-dns]: https://tailscale.com/kb/1081/magic-dns
2020-10-22 22:47:18 +02:00

44 lines
1.1 KiB
Nix

{ lib, buildGoModule, fetchFromGitHub, makeWrapper, iptables, iproute }:
buildGoModule rec {
pname = "tailscale";
version = "1.0.5";
src = fetchFromGitHub {
owner = "tailscale";
repo = "tailscale";
rev = "v${version}";
sha256 = "0ib2s694kf5iz5hvrlzfs80z0931dhva7yir80crq0pji9y4rp7b";
};
nativeBuildInputs = [ makeWrapper ];
CGO_ENABLED = 0;
vendorSha256 = "0l9lzwwvshg9a2kmmq1cvvlaxncbas78a9hjhvjjar89rjr2k2sv";
doCheck = false;
subPackages = [ "cmd/tailscale" "cmd/tailscaled" ];
preBuild = ''
export buildFlagsArray=(
-tags="xversion"
-ldflags="-X tailscale.com/version.LONG=${version} -X tailscale.com/version.SHORT=${version}"
)
'';
postInstall = ''
wrapProgram $out/bin/tailscaled --prefix PATH : ${
lib.makeBinPath [ iproute iptables ]
}
'';
meta = with lib; {
homepage = "https://tailscale.com";
description = "The node agent for Tailscale, a mesh VPN built on WireGuard";
platforms = platforms.linux;
license = licenses.bsd3;
maintainers = with maintainers; [ danderson mbaillie ];
};
}