summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ds/dsnet/package.nix
blob: 07b9a7aaed98c81ecc108fee413bf14d6ea5c7a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{
  lib,
  stdenv,
  fetchFromGitHub,
  buildGoModule,
}:

buildGoModule (finalAttrs: {
  pname = "dsnet";
  version = "0.8.1";

  src = fetchFromGitHub {
    owner = "naggie";
    repo = "dsnet";
    tag = "v${finalAttrs.version}";
    hash = "sha256-CKDtILZMWFeSU5nTSguM2fi0BCFdvR2LqELIZ6LYOMk=";
  };
  vendorHash = "sha256-Q2Ipj9yZ+/GUBEmDvgwFLLww7EXnbvdvj/shGQnh1G8=";

  subPackages = [ "cmd" ];

  postInstall = ''
    mv $out/bin/cmd $out/bin/dsnet
  '';

  # The ldflags reduce the executable size by stripping some debug stuff.
  # The other variables are set so that the output of dsnet version shows the
  # git ref and the release version from github.
  # Ref <https://github.com/NixOS/nixpkgs/pull/87383#discussion_r432097657>
  ldflags = [
    "-w"
    "-s"
    "-X github.com/naggie/dsnet.VERSION=${finalAttrs.src.tag}"
    "-X github.com/naggie/dsnet.GIT_COMMIT=${finalAttrs.src.tag}"
  ];

  meta = {
    description = "Fast command to manage a centralised Wireguard VPN";
    homepage = "https://github.com/naggie/dsnet";
    changelog = "https://github.com/naggie/dsnet/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.mit;
    platforms = lib.platforms.linux;
    maintainers = [ lib.maintainers.naggie ];
    mainProgram = "dsnet";
  };

})