about summary refs log tree commit diff
path: root/pkgs/by-name/mo/mosdns/package.nix
blob: e38eea0285512e147b14c181eba5233fdf4635d5 (plain) (blame)
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
48
49
50
51
52
53
{
  lib,
  buildGoModule,
  fetchFromGitHub,
  testers,
  mosdns,
  stdenv,
  installShellFiles,
}:

buildGoModule rec {
  pname = "mosdns";
  version = "5.3.1";

  src = fetchFromGitHub {
    owner = "IrineSistiana";
    repo = "mosdns";
    rev = "refs/tags/v${version}";
    hash = "sha256-QujkDx899GAImEtQE28ru7H0Zym5SYXJbJEfSBkJYjo=";
  };

  vendorHash = "sha256-0J5hXb1W8UruNG0KFaJBOQwHl2XiWg794A6Ktgv+ObM=";

  nativeBuildInputs = [ installShellFiles ];

  ldflags = [
    "-s"
    "-w"
    "-X main.version=${version}"
  ];

  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
    installShellCompletion --cmd mosdns \
      --bash <($out/bin/mosdns completion bash) \
      --fish <($out/bin/mosdns completion fish) \
      --zsh <($out/bin/mosdns completion zsh)
  '';

  passthru.tests = {
    version = testers.testVersion {
      package = mosdns;
      command = "${lib.getExe mosdns} version";
    };
  };

  meta = {
    description = "Modular, pluggable DNS forwarder";
    homepage = "https://github.com/IrineSistiana/mosdns";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ moraxyc ];
    mainProgram = "mosdns";
  };
}