1{ buildGoModule
2, fetchFromGitHub
3, installShellFiles
4, lib
5, sqlcmd
6, testers
7}:
8
9buildGoModule rec {
10 pname = "sqlcmd";
11 version = "1.6.0";
12
13 src = fetchFromGitHub {
14 repo = "go-sqlcmd";
15 owner = "microsoft";
16 rev = "v${version}";
17 sha256 = "sha256-LLRNaY6ArUNoKSWSauCh2RKEGO5+G1OnoCAqMaAfOkY=";
18 };
19
20 vendorHash = "sha256-NVmgAlNQvRj/7poIEWjMyKw2qWMd/HwbdSFHpumnRlo=";
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 mainProgram = "sqlcmd";
51 homepage = "https://github.com/microsoft/go-sqlcmd";
52 changelog = "https://github.com/microsoft/go-sqlcmd/releases/tag/v${version}";
53 license = lib.licenses.mit;
54 maintainers = [ lib.maintainers.ratsclub ];
55 };
56}