1{ buildGoModule
2, fetchFromGitHub
3, installShellFiles
4, lib
5, sqlcmd
6, testers
7}:
8
9buildGoModule rec {
10 pname = "sqlcmd";
11 version = "1.1.0";
12
13 src = fetchFromGitHub {
14 repo = "go-sqlcmd";
15 owner = "microsoft";
16 rev = "v${version}";
17 sha256 = "sha256-sBOCUlhqXShcF+KA7NXaUEC6c5+Rz9zutGOw6i2FSsQ=";
18 };
19
20 vendorHash = "sha256-1KnMFTadgTmHan2E/9+iHRPgakXi9F3tEOnuwGR+FXw=";
21 proxyVendor = true;
22
23 ldflags = [ "-s" "-w" "-X main.version=${version}" ];
24
25 subPackages = [ "cmd/modern" ];
26
27 nativeBuildInputs = [ installShellFiles ];
28
29 preCheck = ''
30 export HOME=$(mktemp -d)
31 '';
32
33 postInstall = ''
34 mv $out/bin/modern $out/bin/sqlcmd
35
36 installShellCompletion --cmd sqlcmd \
37 --bash <($out/bin/sqlcmd completion bash) \
38 --fish <($out/bin/sqlcmd completion fish) \
39 --zsh <($out/bin/sqlcmd completion zsh)
40 '';
41
42 passthru.tests.version = testers.testVersion {
43 package = sqlcmd;
44 command = "sqlcmd --version";
45 inherit version;
46 };
47
48 meta = {
49 description = "A command line tool for working with Microsoft SQL Server, Azure SQL Database, and Azure Synapse";
50 homepage = "https://github.com/microsoft/go-sqlcmd";
51 changelog = "https://github.com/microsoft/go-sqlcmd/releases/tag/v${version}";
52 license = lib.licenses.mit;
53 maintainers = [ lib.maintainers.ratsclub ];
54 };
55}