nixpkgs/pkgs/tools/misc/tbls/default.nix
2024-05-16 16:34:05 +00:00

58 lines
1.4 KiB
Nix

{ lib
, stdenv
, buildGoModule
, fetchFromGitHub
, installShellFiles
, testers
, tbls
}:
buildGoModule rec {
pname = "tbls";
version = "1.75.0";
src = fetchFromGitHub {
owner = "k1LoW";
repo = "tbls";
rev = "v${version}";
hash = "sha256-8bfDahJw+ZUSNqMiKDqqyX2jVPd6Wg3JsD/ATAW/oF4=";
};
vendorHash = "sha256-NafHcWP9xJX2hy8i1TKtBi54cXDKgoxbgwLQjYRBcjU=";
nativeBuildInputs = [ installShellFiles ];
ldflags = [ "-s" "-w" ];
CGO_CFLAGS = [ "-Wno-format-security" ];
preCheck = ''
# Remove tests that require additional services.
rm -f \
datasource/*_test.go \
drivers/*/*_test.go
'';
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
installShellCompletion --cmd tbls \
--bash <($out/bin/tbls completion bash) \
--fish <($out/bin/tbls completion fish) \
--zsh <($out/bin/tbls completion zsh)
'';
passthru.tests.version = testers.testVersion {
package = tbls;
command = "tbls version";
inherit version;
};
meta = with lib; {
description = "A tool to generate documentation based on a database structure";
homepage = "https://github.com/k1LoW/tbls";
changelog = "https://github.com/k1LoW/tbls/blob/${src.rev}/CHANGELOG.md";
license = licenses.mit;
maintainers = with maintainers; [ azahi ];
mainProgram = "tbls";
};
}