summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/md/mdtsql/package.nix
blob: a9202225c896305f54101f8bb9f8c51b93bef37e (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
48
49
{
  lib,
  stdenv,
  buildGoModule,
  fetchFromGitHub,
  installShellFiles,
  buildPackages,
  nix-update-script,
}:
buildGoModule (finalAttrs: {
  pname = "mdtsql";
  version = "0.2.0";

  src = fetchFromGitHub {
    owner = "noborus";
    repo = "mdtsql";
    tag = "v${finalAttrs.version}";
    hash = "sha256-fmv8wJfeJ8Lz6Z5OxggrudUvyJaA+22tCs0x2Dvz+Bw=";
  };

  vendorHash = "sha256-/FpbKpxTYiwWVDRxBn3GmPEhna/a+t4CuVq/bZmsb9w=";

  nativeBuildInputs = [
    installShellFiles
  ];

  postInstall = lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) (
    let
      emulator = stdenv.hostPlatform.emulator buildPackages;
    in
    ''
      installShellCompletion --cmd mdtsql \
        --bash <(${emulator} $out/bin/mdtsql completion bash) \
        --fish <(${emulator} $out/bin/mdtsql completion fish) \
        --zsh <(${emulator} $out/bin/mdtsql completion zsh)
    ''
  );

  passthru.updateScript = nix-update-script { };

  meta = {
    description = "Execute SQL to markdown table and convert to other format";
    homepage = "https://github.com/noborus/mdtsql";
    changelog = "https://github.com/noborus/mdtsql/releases/tag/v${finalAttrs.version}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ xiaoxiangmoe ];
    mainProgram = "mdtsql";
  };
})